Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglasanro/06fb9283a73c0de76318c8ff6b65a9c4 to your computer and use it in GitHub Desktop.
Save douglasanro/06fb9283a73c0de76318c8ff6b65a9c4 to your computer and use it in GitHub Desktop.
Add WordPress CPT to category and tag archives
<?php
/* ----------------------------------------------------------------------------
* Add CPT to category and tag archives
* ------------------------------------------------------------------------- */
function simple_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_types = get_post_types();
$query->set( 'post_type', $post_type );
return $query;
}
}
add_filter( 'pre_get_posts', 'simple_add_custom_types');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment