Created
April 24, 2014 14:32
-
-
Save brycejacobson/11256777 to your computer and use it in GitHub Desktop.
Add custom post types to archives in WordPress
This file contains hidden or 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 | |
// Add custom post types to archives | |
function namespace_add_custom_types( $query ) { | |
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
$post_types = get_post_types( '', 'names' ); | |
$query->set( 'post_type', $post_types); | |
return $query; | |
} | |
} | |
add_filter( 'pre_get_posts', 'namespace_add_custom_types'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment