Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created April 25, 2013 06:05
Show Gist options
  • Save spencejs/5457823 to your computer and use it in GitHub Desktop.
Save spencejs/5457823 to your computer and use it in GitHub Desktop.
Add Post Type to Main Query, Categories Query, and Tags Query
// Add Best Albums to Main Query
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_my_post_types_to_query( $query ) {
if ( (is_home() && $query->is_main_query() && !is_admin()) || (is_category() && $query->is_main_query() && !is_admin()) || (is_tag() && $query->is_main_query() && !is_admin()) )
$query->set( 'post_type', array( 'post', 'best_albums' ) );
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment