A Guide to Re-Ordering WordPress Blog Posts

For a high end content management system, WordPress sure makes it difficult to implement seemingly simple functionality every now and then. If you’ve ever tried to change the default order of how blog posts appear on your site then I’m sure you can relate.

WordPress orders blog posts based on the date and time that they were published and there isn’t a built-in option available that lets you change that default order. Thankfully, there are a few ways to get the job done.

In this post, we’ll walk you through three different ways to re-order your blog posts and point you to relevant resources for more information. But before we begin, let’s get some basics out of the way.

The Problem With WordPress' Default Post Order

Post sorting in WordPress is actually pretty straightforward and can be summed up in a few words: reverse chronological order. In simple English, this means that by default WordPress handles the post order based on the timestamp of when it was published.

In addition, there is a slight difference with how post sorting works on the WordPress frontend versus how it works on the backend. For instance, if we have a blog post series on how to setup a WordPress blog from scratch then you have two different options for sorting the individual posts on your site’s backend – by title and by date.

Sorting by title on the backend makes the post series easier to follow.

Unfortunately, even this little bit of functionality isn’t available to us on the frontend by default. Here, the posts are listed in reverse chronological order i.e. they’re ordered by date, and there aren’t any options available to re-order them.

Sure it may not be a problem all the time but when you’re publishing, say, a series of posts then this lack of functionality leads to poor UX design. Having your readers start at the end and read up is a bit much. Thankfully, there are a few different ways you can re-order your blog posts and have them appear the way you want them to on the frontend.

3 Ways to Re-Order Your Blog Posts

One of the best things about WordPress is that there’s (almost) always a way to incorporate additional functionality. In this section, we’ll present three solutions to re-order your blog posts on the frontend – manual, coding, and plugin options.

Method 1: Change the Post Dates Manually

Since WordPress orders blog posts based on their timestamp, the easiest way to force a different post order is to manually change each post’s date. This option allows you to enforce any order you want on a selected set of posts giving you more control over post sorting.

  1. Login to your WordPress admin panel and navigate to Posts > All Posts.
  2. Click on the post you want to have appear first i.e. at the top. You’ll be redirected to the Edit Post screen.
  3. In the Publish box on the right-hand side of the screen, click on the Edit link next to the Published on: section.
  4. Note down the date and time the post was published on your site. In this case, the post was published on January 18, 2017 at 7:35 a.m.
  5. Navigate back to the All Posts screen. Select the post you want to have displayed next in line and, following Step 3, head over to its Published on: section and click the Edit link once again.
  6. Change the post’s Published on: timestamp to one that pre-dates the post that is ahead of it in the queue. Doing this ensures that this post will be published after the first post on the frontend. We’ll reset the timestamp on this date to January 18, 2017 at 7:34 a.m.
  7. Repeat Step 5 and Step 6 until all of the blog posts are in the order you want them in. Here’s how our post series looks now:

Although this method is incredibly easy to implement, it becomes difficult to manage when you have a bunch of posts on hand that need reordering. Additionally, it’s ineffective when the timestamp is an important element of the post itself, for instance, in the case of news articles.

Method 2: Code Your Own Custom Solution

WordPress is an open-source content management system which means that you can take matters into your own hands by adding custom code to its core files. In the grand tradition of doing the bare minimum, we’ll add a simple function to the active theme’s file.

Note: Remember to create a backup of your entire site before you begin.

  • Login to your cPanel or FTP client and navigate to your active theme’s functions.php file. (It should be in the /wp-content/themes/active-theme directory.
  • Open the functions.php file in a text editor and add the following lines of code to it:


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 ' );

  • Save the file and refresh your site’s blog page. You’ll notice that the posts will be sorted by title on the frontend.

The downside of this method is that all of your posts will be ordered by title on the frontend. If you’re programming literate then you can customize the code to order a selection of posts only. And if you’re looking to take things even further, you can also create your own custom plugin to implement post sorting functionality.

Method 3: Use a Plugin

There’s a plugin for everything – even re-ordering blog posts on your WordPress site. Post Types Order and Intuitive Custom Post Order are both great, free solutions that tackle the post sorting problem. We’ll show you how you can get started with the Post Types Order plugin.

  • Login to your WordPress admin panel and head over to Plugins > Add New.
  • Search for the Post Types Order plugin in the Add Plugins screen. Install and activate it once you’ve found it.

  • Once you’ve activated the plugin, head over to its settings page by navigating to Settings > Post Types Order.

  • Configure the plugins settings and click the Save Settings button to continue.
  • Head over to Posts > All Posts to begin re-ordering the blog posts.
  • Drag and drop the posts into whichever order you like. In the screenshot below, we’re simply arranging our post series in ascending order.

Once you’re done it should look something like this:

The difference here is that the timestamp of the individual blog posts is unaffected. Even though the second post in the series was published an hour after the first post and the third post, it appears second in line. Whichever order you go with will automatically be set onto the frontend.

Conclusion

Although WordPress doesn’t offer options to re-order blog posts out of the box there are several ways you can get the job done on your own. Depending upon the number of posts you want to reorder, the sorting order you wish to achieve, and your level of technical expertise, you can go with any one of the options we covered:

  1. Change the post’s dates manually if you only need to re-order a handful of posts.
  2. If you’d like to re-order all of your posts in alphabetical order then simply add in a few lines of code to your theme’s functions.php file.
  3. If you’re not particularly programming literate, use the Post Types Order plugin to drag and drop selected posts into place.

Do you have any questions about re-ordering blog posts in WordPress? Let us know in the comments section below!

Leave a Reply

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

close

Copy and paste this code to display the image on your site