Arranging posts in a custom order will be much easier if you use Meta Box plugin and the two extensions Meta Box Builder and MB Admin Columns. Compared to arranging posts by modifying the published date, which is time-consuming, Meta Box plugin and these extensions will do it more quickly in a blink of an eye for you.

First, you need to download the Meta Box plugin here. Besides the free plugin providing the framework to create custom fields, you might need to buy Meta Box Builder. It helps you create custom fields easily with intuitive UI. Or you can use a free online tool called Online Generator. If you’re a coder, you can code yourself and don’t need these tools.

Additionally, you should use MB Admin Columns extension to manage the posts and view the order more easily in the WordPress admin.

After installing and activating these plugins, follow these steps below to manually reorder posts with Meta Box.

Step 1: Create a custom field to enter the ordinal number for posts

Meta Box Builder can help you easily create custom fields without touching any line of code. In the Dashboard, go to Meta Box > Custom Fields, click Add New button to create a new field group.

Add new Custom Fields

As we create a field to enter number, you can choose Text field or Number field in the left column. Then, a new column on the right will appear to let you fill in the Title and Label of the field. I named this field Order field to easily identify it. Now, look at the field’s ID that I marked, you can use the automatically generated ID by Meta Box builder or replace it with your own ID for easy memorizing. After that, copy this ID to paste to the code in the next step. To finish this step, click Publish.

Create a custom field to enter the ordinal number for posts

Step 2: Enter the custom ordinal number for posts

After creating the custom field, move to Post Editor, open a post that you want to reorder, and find the created field tab. In this tab, enter the number that you want this post to display and Updated the article.

Updated the article

To easily manage the order of posts, MB Admin Columns will help you create an ordinal column in the post list.

What you need to do is coming back to the Meta Box Builder. In the created custom field, choose Advanced > Add Attribute and enter these parameters:

Add Attribute in Meta Box Builder

You must use admin_columns to integrate with MB Admin Columns. And after date is the position to display the ordinal column so you can replace it with after tag, after category or any position as desire. Finally, don’t forget to click Update.

If you use code, simply add this code when you create meta box.

‘admin_columns’ => ‘after date’

Now when you go to the post list, you will see a new column displaying the value of the custom field we entered before. That’s so convenient to control and manage the post order, right? However, this extension is not compulsory so it’s optional to use it.

Enter the custom ordinal number for posts

Step 3: Reorder posts on the front end

Your homepage still doesn’t display the post in the created order above unless you add these code to the ‘functions.php’ file of your theme.

function memory_custom_post_order_sort( $query ) {
    if ( $query->is_main_query() && is_home() ) {
        $query->set( 'orderby', 'meta_value' );
        $query->set( 'meta_key', 'mb_order' );
        $query->set( 'order', 'ASC' );
    }
}
add_action( 'pre_get_posts', 'memory_custom_post_order_sort' );
  • 'pre_get_posts': the hook that fires just before the post query is created
  • is_home(): ensure that the reordering happens on the homepage only.
  • query->set( 'orderby', 'meta_value' );
    $query->set( 'meta_key', 'mb_order' );
    $query->set( 'order', 'ASC' );
    These 3 lines arrange your posts in ascending order according to the value of the field with id 'mb_order'. Replace ‘mb_order’ with your field ID if you use another ID.
    ‘ASC’: display your post in ascending order.

After saving the code, go to your homepage to see the result. You see, your posts are reordered as you want.

Final thought

Instead of changing the published date to organize your posts, now, you just need a few simple steps with the help of the Meta Box plugin and the Meta Box Builder extension. Even if you are not a coding expert, the above steps are not difficult for you, right?

Leave a Reply

Your email address will not be published. Required fields are marked *