Skip to content

Instantly share code, notes, and snippets.

@romuloctba
Created April 1, 2015 09:40
Show Gist options
  • Select an option

  • Save romuloctba/1352d85a160440af20b1 to your computer and use it in GitHub Desktop.

Select an option

Save romuloctba/1352d85a160440af20b1 to your computer and use it in GitHub Desktop.
Include all post types in archive page
function archiveAll( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'myCustomPostSlugHere'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'archiveAll' );
@romuloctba
Copy link
Copy Markdown
Author

This solves the problem with, for example, the 'categories widget', that shows the total count of posts, but only list the post-type 'post' in the archive page. ;) Nice
by csstricks.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment