By default WordPress sorts posts in reverse chronological order (from newest to oldest), or rather by the date they were published. This works for most publishers, but there are situations in which you might need to reorder them. Perhaps you have a custom post type in which you need to rearrange or a WooCommerce product you would like to appear at the top of your shopping page. Check out these different solutions and tricks to reorder posts in WordPress.
How to Reorder Posts in WordPress
Below are a couple different approaches and options you can take to reorder your posts.
- Reorder Posts by Changing Publish Date
- Reorder Posts in WooCommerce
- Reorder Posts With a Plugin
- Reorder Posts With Code
Option 1 – Reorder Posts by Changing Publish Date
Most WordPress themes use the ‘orderby‘ post date parameter. So the first method you can use to reorder posts is by simply changing the publish date on the post. This can be a quick way to reorder one or two posts, but WordPress doesn’t have a very great way to bulk reorder. If you need to do a lot at once, we recommend using one of other options below. If we take a look at the posts below, we can see that these two articles were published on the same date. And the last one to publish is the one which shows up at the top of our blog. However, in this case, we want the previous post to show up first. So to change the order we can change the publish date. To do this click on “Edit” under the post title.
On the right-hand side, you select a new date for when it was published on (one that is more recent than the other one), and then click “Update.”
You can see that the post is now above the other one at the top. And this will reflect on your blog, as everything is shown in reverse chronological order.
If you don’t want to drastically change the dates, you could also simply change the time (as seen below, WordPress by default uses military time). Even setting it a second later will result in it reordering the post. Changing only the time can be useful for example if you have an automated RSS email marketing campaign about to run and you need it to grab posts from that day, but you simply need to reorder one or two posts.
Option 2 – Reorder Posts in WooCommerce (Built-in Drag and Drop)
A lot of people might not know this but WooCommerce actually has a built-in drag and drop functionality in their plugin. To use it, click into your “Products” page and click on “Sorting” at the top. You can then hover over a product and drag them around to change their order. And yes, this directly affects the order in which they appear on the frontend of your shopping page.
Another way to reorder products in WooCommerce is to change the custom meta “menu order” field. If you click on your product, under the “Advanced” tab, you can assign a product a menu order such as 0, 1, 2, 3, 4. This would then reflect in the dashboard and the frontend of your shop. You can also use negative numbers. So for example, if you have a product that you want to appear at the top and you already have previously assigned menu orders, you could use -1 or -2. Some themes will also have menu orders available to change within custom post types.
You can also quickly change the catalog on the frontend of your shop page by changing the default product sorting. To do this click into WooCommerce settings and into Display under the “Products” tab. You can then select the following from the default product sorting:
- Default sorting (custom ordering + name)
- Popularity (sales)
- Average rating
- Sort by most recent
- Sort by price (asc)
- Sort by price (desc)
And lastly, you can also use a plugin to rearrange products in both WooCommerce as well as EDD, see the next option below.
Option 3 – Reorder Posts in WordPress With a Plugin
By far one of the easiest ways to reorder posts in WordPress is with a plugin. We highly recommend the free Post Types Order plugin. This allows you to reorder posts, pages, custom post types, and products (WooCommerce and EDD) using a drag and drop sortable JavaScript capability.
It currently has over 400,000 active installs with a 4.5 out of 5-star rating. You can download Post Types Order from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. After activating it click into “Post Types Order” under settings and you can enable the types of posts you want the reorder interface to show up on.
Then under that post type you will see a new menu called “Re-order.” You can then drag and drop the posts within according to the order you want them to appear in. In this example, we are doing it on a Testimonial custom post type.
Because the WordPress theme has custom styles in place for this custom post type rearranging them with the plugin allows us to control exactly how they are displayed on the page. So in a sense, reordering with this plugin can even affect your site’s design and feel.
And remember, you can pretty much reorder any type of post with the plugin. It’s quick and easy!
Option 4 – Reorder Posts in WordPress With Code
Your last option would be to reorder posts in WordPress with custom code. Here is an example of sorting your posts on the frontend in ascending order by title. To make sure your customizations stay in place when updating your theme, start by making a backup of your site and creating a child theme. Then, place this in your theme’s functions.php file.
function change_posts_order( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', ' change_posts_order ' );
You could also hire a WordPress developer to create your own custom ordering query.