How to Customize WordPress Post Order?


For Blogger WordPress is the best choice for blogging. In WordPress theme every one wants to change Post order and page order in navigation menu or on home page, for that in this post I am going to show how to make these changes in Post order. Here are few ways to customize the sort order of posts in WordPress.

Customize WordPress Post Order Manually

To customize post order manually, open your theme document and use the following code:

// display posts organized by title in ascending order
<?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?>
<?php if( $posts ) : ?>
		<h1>Ordered by Post Title (Ascending)</h1>
		<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
			<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
			<p><?php the_content(); ?></p>
		<?php endforeach; ?>
<?php endif; ?>

This code will display the specified number of posts in ascending order, according to post title. You can customized this code in countless ways according to your own requirements.

There is another useful post-ordering trick involves customizing the post order of, say, categories only, as one might do in an archive or service directory. To limit custom ordering to only categories, replace the first line of the previous loop example with this:

<?php if (is_category()) { $posts = query_posts( $query_string . '&orderby=title&order=asc' ); } ?>

Also you can add another endif statement to the end of the loop like this:
<?php endif; ?>
<?php endif; ?>
As well you can replace is_category() in that first line with the is_whatever() statement of your choice:

  • is_home()
  • is_single()
  • is_author()
  • is_search()
  • is_archive()

For more detail, check out the WordPress Codex.

Customize Post Order Automatically Using Plugins

Let’s have a look on to some easier custom-sorting methods by using WordPress Plugins.

1. Custom Query String Reloaded for WordPress

Custom Query String Reloaded is one of the most commonly used WordPress plugins. Custom Query String (CQS) provides an Admin Options panel whereby users may specify any number of custom post queries. CQS enables custom sorting of many different types of queries.

2. Smart Sort WordPress Plugin – Sort posts by Custom Field

This plugin allows you to place a sort bar, with options to sort the list of posts by any custom field. You can place the sort bar above or below a list of posts in a category or archive or anywhere in your template.

3. aStickyPostOrderER : Plugin To Change WordPress Post Order

If you’d like to re-arrange the order that WordPress displays posts this plugin might help.
With aStickyPostOrderER you can customize the order of appearance of posts per category, per tag – or over-all – in a WordPress blog. Useful for using WordPress as a Content Management System (C.M.S.).

4. WP-Snap! WordPress Plugin

WP-SNAP! WordPress Plugin creates an alphabetical listing of ABCDEF, etc. links on a category template file. When you click “A”, “D”, or “Z”, any post titles that begin with that letter are showcased.

5. Sort Category Posts by Title

This plugin looks like a quick and easy way of sorting category posts in ascending alphabetical order according to post title. According to the plugin’s homepage, “WordPress Sort Category Posts By Title” was designed for WordPress 2.0.2 and only customizes the sort order of posts displayed in category view — it will not effect the ordering of posts seen elsewhere (e.g., the home page) in the site. The code for this plugin seems clean, simple, and just begging for further exploration and adaptation 😉

Leave a Reply

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

You May Also Like