Ad Inserter
94Manage Google AdSense ads, banners, ad rotation, sticky widgets, AMP ads, ads.txt, tracking, header and footer...
Sort posts on-the-fly without making a new SQL query
Sort Query Posts is a WordPress plugin designed to sort posts dynamically without executing a new database query, which can enhance performance. It allows you to reorder various types of posts, including custom post types, using a simple function call before displaying the posts.
The plugin supports multiple sorting criteria such as author, date, title, and more. It is particularly useful for developers who need to adjust the order of posts returned by WordPress queries without impacting site performance.
Best for: This plugin is suitable for developers looking to efficiently sort posts on their WordPress sites.
What it does well
Where it falls short
Sort Query Posts offers a straightforward solution for sorting posts without performance drawbacks, but its age and limited sorting options may be a concern for some users.
Tubal's own description of Sort Query Posts, lightly tidied.
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'); ?>
Other plugins for custom content structures.
Manage Google AdSense ads, banners, ad rotation, sticky widgets, AMP ads, ads.txt, tracking, header and footer...
ACF helps customize WordPress with powerful, professional and intuitive fields. Proudly powering over 2 millio...
Checkout Field Editor (Checkout Manager) for WooCommerce – The best WooCommerce checkout manager plugin to man...
Easily reorder posts, pages, custom post types, and taxonomies with intuitive drag-and-drop sorting in the Wor...
The #1 user-rated activity log plugin for event logging, activity monitoring and change tracking.
Admin UI for creating custom content types like post types and taxonomies