Created
July 31, 2012 23:12
-
-
Save jbreitenbucher/3221594 to your computer and use it in GitHub Desktop.
WordPress: Order Custom Taxonomy Term page by custom key
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
/** | |
* Make sure to order staff on role term pages alphabetically by last name | |
* | |
* @author Jon Breitenbucher <[email protected]> | |
* @version SVN: $Id$ | |
* @param array $query Default query arguments | |
* @return array modified query arguments | |
* | |
* @since 2.0 | |
* | |
*/ | |
function tech_staff_alpha_order_posts( $query) { | |
if ( $query->is_main_query() && !is_admin() && is_tax( 'taxonomy' ) ) { | |
$query->set( 'meta_key', 'it_last_name_text' ); | |
$query->set( 'orderby', 'meta_value' ); | |
$query->set( 'order', 'ASC' ); | |
return $query; | |
} | |
} | |
add_action('pre_get_posts', 'tech_staff_alpha_order_posts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment