Created
May 8, 2018 19:10
-
-
Save cparkinson/2ac2555d51bed703ce2d39e14d1de699 to your computer and use it in GitHub Desktop.
Order posts in a certain category by date ASC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
For when there's a category of team bios. | |
If you create them up in alphabetical order, | |
then the reverse date order will retain that order | |
This goes in functions.php | |
*/ | |
/*Order bio Posts in reverse date order, set limit at 30 posts */ | |
function prefix_modify_query_order( $query ) { | |
if ( (is_main_query()) | |
&& (is_category( $category = 'team-bios' ))) { | |
$query->set( 'order', 'ASC' ); | |
$query->set('posts_per_page', 30); | |
} | |
} | |
add_action( 'pre_get_posts', 'prefix_modify_query_order' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment