>
Download This Plugin | |
Download Elegant Themes | |
Name | Sort Query Posts |
Version | 1.1 |
Author | Túbal Martín |
Rating | 100 |
Last updated | 2012-09-04 12:11:00 |
Downloads |
9457
|
Download Plugins Speed Test plugin for Wordpress |
Home page PageSpeed score has been degraded by 0%, while Post page PageSpeed score has been degraded by 0%
Sort Query Posts plugin added 16 bytes of resources to the Home page and 11 bytes of resources to the sample Post page.
Sort Query Posts plugin added 0 new host(s) to the Home page and 0 new host(s) to the sample Post page.
Great! Sort Query Posts plugin ads no tables to your Wordpress blog database.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).
order_by
and order
values of the query_posts function except meta_value
and meta_value_num
(which require a database query).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:
This is specially useful in two cases:
query_posts()
) to be shown more than once on the same page and ordered differently.Examples:
<?php sort_query_posts_by('title', 'desc'); ?>
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.
<?php sort_query_posts_by('ID'); ?>
The example above will sort posts by their ID in ascending order.
<?php sort_query_posts_by('rand'); ?>
The example above will sort posts randomly. When sorting randomly $order
is ignored.
Plugin developed by Túbal Martín at http://www.margenn.com.