Created
May 24, 2014 15:48
-
-
Save robincornett/ea4f46da7e47e3ee0266 to your computer and use it in GitHub Desktop.
Example function of how to set the order of posts for an archive or taxonomy--specifically for a custom post type, but can be used anywhere posts are listed, such as a specific category/taxonomy.
This file contains 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
<?php | |
/* | |
* This function is part of Simple Staff for Genesis. Extracted for educational purposes. Could be used also | |
* in a theme's functions.php file, if you're not working with a plugin. Do not include the opening tag. | |
*/ | |
add_action( 'pre_get_posts', 'simple_staff_order', 9999 ); | |
function simple_staff_order( $query ) { | |
if ( $query->is_main_query() && ( is_post_type_archive( 'staff' ) || is_tax( 'department' ) ) ) { | |
$query->set( 'orderby', 'menu_order' ); | |
$query->set( 'order', 'ASC' ); | |
$query->set( 'posts_per_page', -1 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment