Ask WPUniversity: How do I alphabetically sort posts in a category?

Alphabetical Post Sorting within a category: How To

Mabel asked:

Can you suggest a plugin that will sort posts under a specific category in alphabetical order?

For this post, we’re assuming that Mabel wants to display posts from a category in alphabetical order.

If you’re comfortable working with WordPress theme templates, this can be done using the standard get_posts() function. If you’re not keen on diving into theme code, you can achieve something similar with the Mini Loops plugin.

Mini Loops Plugin Page

Using the Mini Loops Plugin

The Mini Loops plugin is essentially a shortcode for creating WordPress queries.

Add some options (arguments) to the shortcode and Mini Loops will spit out the results.

For alphabetically sorting posts in a category, we’d use the following shortcode:

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

Let’s go through what each option means.

  • categories=”29″: The IDs of the categories I want to include in this loop.
  • order_by=title: Tells the loop to sort the results by title.
  • order=ASC: Display results in ascending order (alphabetical).
  • number_posts=100: A high number so that all results are shown on the page.

You can find a full list of options under “other notes” on the Mini Loops plugin directory page.

What does the output look like?

Here’s an example from a test blog I created with the Theme Unit Test Data:

Screenshot - Alphabetical Posts

Bonus: Use Mini Loops in your sidebar.

Aside from the shortcode, you can also use the Mini Loops plugin for sidebar widgets:

Mini Loops Widget

The widget includes a plethora of options for you to choose from.

(Hope this helps you out, Mabel!)

About the author

3 responses to “Ask WPUniversity: How do I alphabetically sort posts in a category?”

  1. Mabel Tola-Winjobi says:

    Thanks for the help.

  2. Daniel Keith says:

    Hi Ben,
    Great post. Mini Loops gave my website a very professional look.
    Kindly, suggest any plugin to decrease the load time of a website.

Leave a Reply

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