This works for me:
function namespace_add_custom_types( $query ) {
if( is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'YOUR_CUSTOM_POST_TYPE', 'nav_menu_item'));
return $query;
}
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
Related Posts:
- Custom Post Type Archives by Date and Taxonomy
- Custom post types – Use post_id in permalink structure when using has_archive => true
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Taxonomy count per Post type
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Archive page with multiple taxonomies rewrite
- show tags of custom post type ONLY
- Create permalink structure for one taxonomy archive per custom post type
- Taxonomy archives based on Custom Post Type
- Taxonomy page returns 404 page not found
- How would I leverage custom Taxonomies in this scenario?
- Custom post type tag archives don’t work for basic loop?
- Removing CPT slug from URL results in 404 error for archive page
- Regex problem in an add_rewrite_rule
- Rewrite custom post & taxonomy to share same URL path
- How do I list terms of a custom taxonomy at i.e. domain.com/brands/
- Custom post type with tags
- Registering tags taxonomy for a custom post type
- Is slug “type” reserved and can’t be used in taxonomy rewrite?
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Permalinks for Taxonomy and Custom Post Type
- Category page only displaying the posts from a custom type
- How to list custom post types?
- custom taxonomy archive by year
- How to make a custom taxonomy selectable in post publish area?
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- Hierarchical Custom Post Types – Show only parent on tax archive?
- How can I display an archive of only one category of my custom post type?
- Change Permalink Structure for Tag.php template
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- CPT Archive with core Category
- Tag page with Custom Post Types not returning any posts
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- Taxonomy custom post type URL
- How to build custom route by adding taxonomies to URL ? ex: www.demo.com/communities/palo-alto/
- Set a CPT slug as a base name for all the taxonomies
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- How to get list of taxonomy slugs ordered parents>childs?
- Taxonomy in URL
- Best way to specify “article type” in URL
- How can I create an automatic drop down menu with my tags?
- Need help deciding on a taxonomy
- Get Posts by Category, Tag , and CPT Taxonomy
- Use the custom post type archive for taxonomies?
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Archive page for custom post type and custom taxonomy
- Why does my URL keep returning 404 error code?
- Custom post type, taxonomy and admin bar
- Advanced archive url structure (category, tag and date)
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- Define multiple prefixes for custom post type
- Custom permalink structure for custom post types including multiple taxonomy
- get taxonomies from terms
- Custom post types not showing on the standard WordPress Category page
- Archive for custom taxonomy
- Automatically / dynamically populating tags in custom post type
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Rewrite url post_tag for custom post type
- Custom Post Type tag taxonomy “Page Not Found”
- Default taxonomy ‘post_tag’ added to CPT managing by custom role : nothing in the metabox
- Taxonomy count per Post type
- Archive.php is not displaying tags
- How can I set up the URL for a category archive for a custom post type?
- Generate daily archive whenever any post type is added
- custom post type tags
- Show custom category archive as front page and remove taxonomy slug from urls
- Remove date rewrite rule for custom post type archive page
- Taxonomy term archive claims there are no posts, but there are. How to resolve?
- Custom Taxonomy archive with url parameters
- Custom permalink with child taxonomy terms
- Custom post type posts don’t show in archive widget
- Custom post type archive with page as parent url
- Pagination custom post type not working with rewrite slug
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Invalid Taxonomy
- URL Rewrite – Page Archive
- get_post_permalink() and custom permalink rewriting
- pre_get_posts works in post type archive but not in single post
- Query Custom Post Type by Taxonomy
- Copying over taxonomy structure from one CPT to another
- Display ONE taxonomy and its assigned pages
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- Page that lists publications by classifying them by taxonomy
- How to display all terms from all taxonomies in post, but separately for each taxonomy?
- Custom post type structure + permalink structure
- Custom post type pagination problem – page 1 and 2 show same content
- Single taxonomy for different custom post types
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- Custom Post Type and Taxonomies, creating the corresponding template file and loop the data
- Archive page for a custom post type using WPML
- Generating List of Tags from Custom Post Type
- Customize category URL
- Custom Post Types Archives and daily/monthly joke
- rewrite rules add a folder in the path
- Custom Taxonomy in Permalink from post type
- Sharing a custom taxonomy – No posts?
- show only one category posts in admin
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- How to list custom taxonomy terms without the hyperlinks?