-
-
Save anonymous/b216cc899ce94f2fb4f7 to your computer and use it in GitHub Desktop.
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 | |
/* | |
* Show posts assigned to 'International (intl)' Edition | |
* under all editions. | |
* | |
* http://wordpress.org/support/topic/show-posts-from-multiple-categories-1?replies=3#post-4910968 | |
*/ | |
function wpse10691_better_editions( $query ) { | |
$get_edition = get_query_var( 'category_name' ); | |
if( $get_edition !== '' ) { | |
$edition_obj = get_term_by( 'slug', $get_edition, 'category' ); | |
if( $edition_obj && !is_wp_error( $edition_obj ) ) { | |
$edition = $get_edition; | |
} | |
} | |
// Modify main query | |
if( $query->is_category() && isset($edition) && $query->is_main_query() ) { | |
$query->set( 'category_name', $edition.', intl' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'wpse10691_better_editions' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment