Change Order
Image Source: ullajj – Pixabay.com / License: CC0 Public Domain

If you're not happy with the way WordPress sorts and displays your posts by default, then you've got two choices: either (1) change the Loop code (either by changing your WordPress theme or by coding a custom Loop) or (2) pick a plugin. Sometimes, for whatever reasons, you would like a little more flexibility to order posts than WordPress provides out of the box. If you want to sort posts by different criteria, for instance, then there are a number of plugins that can help. Before we look at a few of those plugins, however, let's examine what the Loop is, and how it normally sorts content.

Understanding the Loop

So what is the Loop? Well, it's not just a plot point in Westworld – though, come to think of it, it's not far off, either! The Loop, essentially, is the code that decides what gets displayed on any part of your WordPress-powered site – that is, in your dashboard's list of posts or on the site itself, including the homepage (or blog page, if you've configured your site with a static home page instead of blog posts) or any archive-based page (e.g. category archive, tag archive, etc.).

The Loop operates in a similar way for any self-hosted WordPress site, although WordPress themes or plugins can modify the Loop in a number of ways. The general function is the same, but the specifics can vary quite a bit. The general output of the Loop depends on template tags.

Loop Infographic Excerpt 1
Image Source: Screenshot – WPBeginner.com

When the Loop is triggered to display content, the tags are what determine which content is displayed and in what order. You can see examples of the content's display and its associated template tag in the screenshot below (you can see the entire infographic here at WPBeginner):

Loop Infographic Excerpt 2
Image Source: Screenshot – WPBeginner.com

Here's an example of a very basic WordPress Loop as shown on WordPress.org. Remember that, depending on the WordPress theme that's installed on the WordPress website you're working with, your own code might look different from other examples you can find, but the basic structure should at least be recognizably similar to this:

<?php 
if (have_posts()) { 
    while (have_posts()) { 
        the_post(); 
        // Post Content here 
    } // end while
} // end if
?>

Very simple, this code checks whether there are posts available; and if that is the case, posts are being displayed as long as they are available. If you would like to learn more about the loop, check out the following pages in the WordPress Codex:

Mini Loops Plugin

Mini Loops
Image Source: Screenshot – WordPress.org

Mini Loops is a plugin that lets you create WordPress queries by using shortcodes. By adding certain options or arguments to the shortcode, you change the results of those queries. For example, you can create a new, modified Loop to sort posts within a category alphabetically (instead of by date, which would usually be the default order). Creating this shortcode with these arguments while using the Mini Loops plugin would help you achieve that result:

[miniloop categories="29" order_by=title order=ASC number_posts=100]

That might look confusing and not particularly user-friendly, but once you understand the shortcode options, it's much simpler to fathom:

  • categories='29': This tells the Mini Loops plugin which category (or categories) I want in this loop, by the category's ID number.
  • order_by=title: This argument instructs the loop to sort the results by the title of the post.
  • order=ASC: This tells the Mini Loops plugin to show the results in ascending order – in this case, this translates to an alphabetized sorting based on the post title.
  • number_posts=100: This argument tells the plugin how many posts to include in the results.

There's a lot more that the Mini Loops plugin can accomplish, which you can get an idea of by looking at the full list of options or arguments that are available.

Flexible Posts Widget Plugin

Flexible Posts Widget
Image Source: Screenshot – WordPress.org

The Flexible Posts Widget works specifically in widget-enabled WordPress themes on the sidebar only. But if that's what you're looking for, this plugin may be exactly what you need without adding expense or complexity that you don't need. It allows you to include even more content types in your sidebar, such as filtering your blog posts by more than one criteria. For example, you can filter, sort, and display posts in two or more categories with specific associated tags.

You can also order your posts by a number of different factors, such as title, comment count, publication date, and more. What's more, the plugin allows you to specify whether or not the featured image thumbnail is displayed. One thing to note is that the widget doesn't allow you to include a post excerpt in the display, or create and use a custom link.

Another thing to be aware of: Flexible Posts Widget is highly rated on the repository – 4.8 out of 5 stars, at the time of this post's writing – but it hasn't been updated in a year. We'd advise testing this one out on a cloned and locally-hosted WordPress website first.

Custom Content Shortcode Plugin

Custom Content Shortcode
Image Source: Screenshot – WordPress.org

Custom Content Shortcode is another plugin that's implemented by shortcodes (much like Mini Loops, discussed above) that gives you some powerful control over the content your site displays.

The [content] shortcode gives you display control over posts, pages, custom post types, fields, images, menus, and widget areas. The [loop] shortcode gives you query loop functionality to display, as an example, certain products in a specific category, or excerpts from recent posts you've published on your site, using parameters such as post type, taxonomy, and more.

Custom Content Shortcode boasts a near-perfect rating, and was last updated six months ago. It might take a bit of time to conquer a slight learning curve, but that's probably time well spent if you're looking for a robust, free shortcode-based approach.

Post Types Order Plugin

Posts Types Order
Image Source: Screenshot – WordPress.org

Almost two million downloads, and over 400,000 active installs makes Post Types Order a popular choice. Its ability to create and display custom post-sorting results based on custom post types makes it a highly functional one. Post Types Order also offers a drag-and-drop interface to give you greater control over the order of your posts' display on the front end of your site. Post Types Order enjoys a 4.6 rating on the repository, and has been recently updated as of this post's writing.

Conclusion: Post-Sorting Plugins for WordPress

So you have a number of plugin options to explore if you want to change the loop without directly coding a new loop or changing your website's WordPress theme. Of course, since plugins sometimes cease being actively developed by their creators, do your own research before you upload and active any plugin on your site. Check recent reviews.

Finally, don't forget to verify whether the latest version works with the current WordPress core version on the repository page for the particular plugin you're evaluating. Did we leave out your favorite post-sorting plugin? Let us know in the comments section below!