blog

3 Ways to Re-Order WordPress Blog Posts


By default, WordPress posts are ordered based on the date that they were published. And if you’ve ever tried to re-order WordPress blog posts then you know full well that there’s no built-in way to do that.

However, if you do want to move a few posts around then there are three different methods to go about it – (1) manually changing the posts publish date, (2) writing code for a customized solution, or (3) using a plugin that’ll get the job done automatically.

With this in mind, in this post, we’ll step through all three of the options available to you for re-ordering your blog posts. But before we begin, let’s take a quick look at how WordPress handles the default post order.

Let’s get started.

How WordPress handles the default post order (and why it’s a problem)

In a nutshell, WordPress orders blog posts in reverse chronological order. This basically means that how your posts appear on the front-end depends entirely on when you published them. This example sums it up well:

On the back-end interface, we have the option of sorting posts by both the post date and the post title. If you’ve ever published a series of blog posts then you know that sorting by title makes it much more intuitive to follow. However, even this seemingly tiny bit of blogging functionality is denied to us on the front-end.

Sort by title on the back-end

For instance, if you’ve published a series on setting up a WordPress blog then chances are you want the first post of the series to appear at the top of the list and not at the bottom. Not only does it improve the user experience your site delivers but it also makes it easier for the reader to follow the series in the order it was intended to be in.

Fortunately, there are a few ways you can re-order WordPress blog posts to appear in a more logical order on the front-end.

How to re-order WordPress blog posts

WordPress makes it easy for users to integrate additional, custom functionality into the core software. With that in mind, let’s step through three different ways you can re-order WordPress blog posts on the front-end. All three options have their own benefits and the one you ultimately decide to go with depends on your requirements and level of technical knowledge.

Option 1: Change the post dates manually

As we briefly mentioned above, posts with more recent timestamps come before those with older ones. The simplest (and most instinctive) way to re-order WordPress blog posts on the front-end is to change the post dates by hand.

The post's timestamp.

Start off by logging into your WordPress site’s admin panel and navigating to Posts > All Posts. Open the post you want at the top of your series in the Edit Post screen and note down the date and time of when it was published. In our example, the timestamp is February 22, 2017 at 10:19 a.m.:

Editing the post's timestamp.

Now, head back to Posts > All Posts and select the post you want to have appear next in line. Click on the Edit link in the “Published on” section and change the post’s timestamp so that it pre-dates the post that’s intended to be ahead of it in the series’ queue. Following our example, we’ll set the new timestamp to February 22, 2017 at 10:18 a.m. i.e. a minute before the preceding post.

Repeat the same process for all of the posts in your series. Here’s how it should look like on the back-end once you’re done:

Back-end preview of posts.

Changing the post dates manually is incredibly easy to implement if you have a handful of posts that need to be re-ordered. This option isn’t as effective when you have hundreds of posts to re-order or when the timestamp is an important element of the post.

Option 2: Add code for a custom solution

Since WordPress is open source, it allows developers to write custom code to integrate additional functionality to the core software – even if it’s to re-order WordPress blog posts. As always, remember to take a full backup of your site before you mess around with its files.

To get started, login to an FTP client and open up the active theme’s functions.php file by navigating to /wp-content/themes/ACTIVE-THEME/ from the root directory. Next, open up the functions.php file in a text editor of your choice (raw text editor, like Notepad; not MS Word) and insert the following lines of code at the bottom:

function order_posts_by_title( $query ) {
 	if ( $query-is_home() && $query-is_main_query() ) {
 		$query-set( 'orderby', 'title' );
 		$query-set( 'order', 'ASC' );
 	}
 }
 add_action( 'pre_get_posts', ' order_posts_by_title ' );

Once you’re done, be sure to save the file and re-upload it to your site’s themes directory. The result:

Posts sorted by title on the front-end.

Adding this code snippet allows you to re-order WordPress blog posts by title on the front-end. The only downside of using this code is that it will re-order all of your blog posts, permanently. You can, of course, customize it even further to re-order only a selected set of posts.

Option 3: Use the Post Types Order plugin

If you’ve been working with WordPress for some time now then you probably already know that there’s a plugin for (almost) everything. The Post Types Order plugin is a free solution that allows you to re-order WordPress blog posts by simply dragging and dropping them into place.

The first thing you’ll need to do is install and activate the Post Types Order plugin by navigating to Plugins > Add New from your WordPress admin panel.

Once it’s activated, head over to Settings > Post Types Order to configure the plugin’s settings. Here’s a preview of the General settings page:

General settings page preview.

Now, navigate to Posts > All Posts to start re-ordering the blog posts. All you have to do is drag and drop the posts into whichever order you want. Following our example, it should look something like this when you’re done sorting the posts:

Re-order WordPress blog posts using the Post Types Order plugin.

The advantage of using this method is to re-order WordPress blog posts is that the timestamp of each post remains unaltered. Best of all, the posts will appear on the front-end exactly how they do on the back-end.

Wrapping it up

Though WordPress doesn’t offer any post re-ordering functionality right out of the box, implementing your own solution is a cakewalk. We covered three of the easiest ways to re-order WordPress blog posts on the front-end in this post, and hopefully, you’re in a good position now to take things further yourself.

Let’s quickly recap the advantages of each approach:

  1. If you want to re-order only a few posts then changing their timestamps manually is the simplest way to go about it.
  2. Those of you who want to re-order the blog posts based on their title (permanently) instead of the date can add a custom code snippet to their active theme’s functions.php file.
  3. If you want to re-order blog posts without altering their timestamps then using the Post Types Order plugin is an ideal option.

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

my.sendinblue.com/users/subscribe/js_id/1s344/id/4

Click to comment

Leave a Reply

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

Copyright © 2017 'Null Shop;.

To Top