Skip to content

Instantly share code, notes, and snippets.

/mu-plugin1.php Secret

Created December 13, 2013 21:34
Show Gist options
  • Save anonymous/b216cc899ce94f2fb4f7 to your computer and use it in GitHub Desktop.
Save anonymous/b216cc899ce94f2fb4f7 to your computer and use it in GitHub Desktop.
<?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