Plugin info

Total downloads: 11,758
Active installs: 100
Total reviews: 3
Average rating: 5
Support threads opened: 0
Support threads resolved: 0 (0%)
Available in: 1 language(s)
Contributors: 1
Last updated: 9/4/2012 (4866 days ago)
Added to WordPress: 1/15/2011 (14 years old)
Minimum WordPress version: 2.5
Tested up to WordPress version: 3.4.2
Minimum PHP version: f

Maintenance & Compatibility

Maintenance score

Possibly abandoned • Last updated 4866 days ago • 3 reviews

22/100

Is Sort Query Posts abandoned?

Possibly abandoned (last update 4866 days ago).

Compatibility

Requires WordPress: 2.5
Tested up to: 3.4.2
Requires PHP: f

Developers

Languages

Similar & Alternatives

Explore plugins with similar tags, and compare key metrics like downloads, ratings, updates, support, and WP/PHP compatibility.

No similar plugins found yet.

Description

A really simple and lightweight plugin (73 lines of code – comments included) to sort posts on-the-fly without making a new query to the database (improves performance).

Features:

  • Supports all order_by and order values of the query_posts function except meta_value and meta_value_num (which require a database query).
  • Supports changing the order of all types of posts, including custom post type posts and custom post type “archive” posts.

Documentation

This plugin adds the function sort_query_posts_by(string $order_by [, string $order]) to the global context.
The second $order parameter is optional. Its default value is asc (ascending order).

Call this function before the loop to change how posts are ordered.
After calling this function you can show the posts as you normally would.

You can sort posts by:

  • author
  • comment_count
  • date
  • id
  • menu_order
  • modified
  • parent
  • title

This is specially useful in two cases:

  • When you need to reorder the posts returned by the query that WordPress creates from your given URL. Custom post type “archive” posts are a great example of this case.
  • When you need the posts returned by your customized query (e.g. query_posts()) to be shown more than once on the same page and ordered differently.

Examples:


The example above will sort posts by their title in descending order without making a new query to the database.
This way sorting is performance friendly.


The example above will sort posts by their ID in ascending order.


The example above will sort posts randomly. When sorting randomly $order is ignored.

Plugin developed by Túbal Martín at www.margenn.com.

Installation

  1. Upload sort-query-posts folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Use the added function sort_query_posts_by after any wordpress query and your posts will be sorted to your needs.

Frequently Asked Questions

No FAQ available

Review feed

No reviews available

Screenshots

No screenshots available

Changelog

1.1

  • Code refactored for improved performance. Updating is recommended.