For a piece of software withΒ its roots firmly in the world of online writing, WordPress users are often surprised by the absence of what seem like obvious bits of blogging functionality. A classic case in point is the lack of easy default ways to re-order your blog posts.
In this piece, weβll step through two options available to you for solving this problem, pointing you to relevant links and plugins along the way. However, before we get into all of that, letβs start with a bit of background on how post sorting actually works in WordPress.
How WordPress Handles Default Post Order
The story of how WordPress handles default post order is not a particularly long and complicated one β the simple summary is that it does it by post date. Letβs say, for our own mysterious purposes, weβve decided to turn A Tale of Two Cities by Charles Dickens into a series of blog posts. As you can see below, weβve got the option of sorting by both title and post date in the back end:
Unfortunately, even this basic functionality is denied to us on the front end. Here, posts are simply listed chronologically by default, with no options to filter or adjust them:
While this may be a thrilling nod to Dickensβ trailblazing adoption of serialization back in the day, itβs actually a bit of a UX disaster. If weβre trying to encourage people to read a linear narrative, itβs a bit much to ask them to start at the bottom and read up.
Poking around inside default WordPress options, weβre basically presented with two choices at this stage:
- Use sticky post functionality.
- Start retrospectively changing post dates to force the order we want.
The first option is woefully inadequate in terms of the control needed. The second quickly becomes hard to manage when weβre dealing with large pools of content. Itβs also potentially a complete non-starter for sites where the date is a critical component of individual pieces β news sites, for example.
So, long story short β theΒ baked in options to re-order your blog posts are lacking. However, as with most things WordPress, a solution is at hand β two of them in fact.
How to Re-Order Your Blog Posts (with 2 Methods)
One of the great things about WordPress is its flexibility. With that in mind, weβve offered two solutions to re-order your blog posts β bothΒ manual and plugin options. Letβs step through them in turn.
Option 1: Roll Your Own Ordering Solution
One of the many plus points of using WordPress as a blogging or business solution is that if things arenβt quite to your liking, youβve always got the option of stepping in and changing them around yourself.
This doesnβt have to be a dauntingly technical undertaking either. Before we get cracking,Β back up your siteΒ and bone up on yourΒ File Transfer Protocol (FTP) knowledge if necessary. Once youβre ready, come back!
Firstly, letβs have a quick look at a proof of concept change. Once youβve logged into your FTP client, navigateΒ to theΒ functions.phpΒ file in your /wp-content/themes/your-theme folder. Here, weβve added a simple function just to check if control over post order is possible:
function change_query_order( $query ) { if ( $query-is_home() && $query-is_main_query() ) { $query-set( 'orderby', 'title' ); $query-set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'change_query_order' );
Once youβve saved the file and checked our website, we should be looking at our posts sorted in ascending alphabetical order once we refresh the page:
However, kludging together quick and dirty functions at the end of functions.php is a little old-school. Really, this type of business should be taken care of in a custom plugin.
With that in mind, this tutorialΒ is an excellent breakdown of exactly how to go about achieving it. It also includes working code nicely packaged up at GitHub. This seriesΒ is also well worth a look if youβre thinking of rolling up your sleeves and diving into the code yourself.
Option 2: Use the Post Types Order Plugin
This being WordPress, there are of course also existing plugins that tackle this problem of post order. The one weβll look at is the Post Types Order plugin:
While it offers the functionality we require, in addition itβs regularly updated, boasts an impressive 400,000+ active installs, and has rock-solid ratings from a host of satisfied users. Thereβs also a more full-featured premium version of the plugin available β in the shape of the Advanced Post Types Order plugin β for just $35.
Installation is a snap, but youβll be prompted to pop into the pluginβs settings page after activating:
The basic options you see after clicking through are pretty straightforward, with several useful links offeringΒ code samples for places where you may need to step in:
Although the options may look overwhelming, usingΒ the plugin is incredibly simple and works exactly as youβd expect. Once activated, navigate toΒ Posts > All Posts, and youβre free to pick up individual items and rearrange them in the order you want. Below, weβre busy getting that Dickens order the way we want it:
Changes will then automatically be picked up on the front end. For more of a feel for just how easy this is once the plugin is installed, check out the demo video below. Itβs from an older version of the plugin, but it gets the basic point across nicely:
Conclusion
Because WordPress is so flexible, post sorting feels like the kindΒ of functionality that should arrive out of the box, with substantially better default options to hand. Sadly, thatβs not the case. However, we do have manual and third-party options at our disposal for getting things arranged how we want.
In this post, weβve shown you two methods to re-order your blog posts. Letβs recap:
- Create your own custom code: If youβre comfortable with βrolling your ownβ, just a few lines of code is probablyΒ all thatβs required to help arrange things to your pleasing.
- Use an existing plugin: In our tests, the Post Types OrderΒ plugin stood out for its simplicity and ease of use. Having the option of upgrading to a commercial version for more in-depth sorting options is also reassuring.
Do you have any questions on how to re-order your blog posts?Β Get in touch via the comments section below, and make sure you subscribe to the conversation!
Article thumbnail image: HeydarovTabriz / shutterstock.com.
How can I have different sorting of posts on different pages?
I have different categories of blog posts. I want each category sorted differently. One page is of events, and I want to show just the events posts sorted by date. On another page, I have just speakers, and I want to list the speakers just sorted alphabetically.
I too am still looking for a way to do this. I need alphabetically on some pages but to keep as chronologically on others.
The code you provide in this post is wrong in syntax ( use -> insted of – )
I’ve installed Post Types Order and activated it. But I don’t know where the setting is for ASC vs DESC; please give me a pointer. Although I’m quite familiar with PHP, I don’t want to take that approach when there’s a way to just specify the order I need. (My whole reason to use WordPress is to get away from doing custom coded websites to create great websites.)
This plugin is much appreciate because without reversing the built-in order, the blog is useless for my purpose.
Thank you soooo much. In the past I had tried some other plugins but the those never seemed to work for me. So, I gave up on being able to re-order posts.
And, forget about php coding. No way… that would spell big trouble. LOL
The difficulty I was running into (with the other plugs) was that the posts would re-order on the “blog” page, but not in the widget area where they were also displaying – and my need was particularly for the widget area to be re-ordered.
This plugin works like a charm!
Thank you again.
Hi John,
Thanks for this great, informative and useful article. I am using ‘Post types order plugin’ this is amazing and lightweight plugin but this is not working properly for me.
Please tell me how do I use this plugin?
Thanks in advance!
Regards,
~ Vijay Kumar
Hello Vijay,
Without specific information as to what problem you are experiencing, I’m afraid I can’t help.
Cheers,
John
GREAT! Just the functionality that I have been looking for. The $64,000 Question is: will it work for posts displayed using the Divi Blog Module?
I had to ask for help form the developer on the $35 premium mode to re-order my posts. But I am not very adept at these things.. They obliged quickly.