Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plugin Name: Change post order by category
Plugin URI:
Description: Order Blog category by date, rest alphabetically.
Author: Damien Carbery
Version: 0.1
// Change the post order to ascending by title for all categories except the 'blog' category.
add_action( 'pre_get_posts', 'dcwd_change_post_order_by_category' );
function dcwd_change_post_order_by_category( $query ) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( ! is_category( 'blog' ) ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'asc' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.