Skip to content

Instantly share code, notes, and snippets.

@itsjusteileen
Forked from braddalton/functions.php
Last active October 19, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsjusteileen/0c4b27e845f3bba63d348a3ff180f0d6 to your computer and use it in GitHub Desktop.
Save itsjusteileen/0c4b27e845f3bba63d348a3ff180f0d6 to your computer and use it in GitHub Desktop.
Wordpress Reverse Order Posts in Category Archive
/**
* Add lines five to 10 to your child theme's functions.php file
*/
function change_category_order( $query ) {
if ( $query->is_category('8') && $query->is_main_query() ) {
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'change_category_order' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment