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?
- Separate archive template to show posts and CPT by same category/taxonomy
- Custom Taxonomy archive with url parameters
- How to Filter custom post type by taxonomy?
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Is it possible to have dedicated page for parent/child taxonomy?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- Custom rewrite url category
- Rewrite Question Mark in Post Template to Make it Pretty URL
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Custom post taxonomies as tax_query terms?
- Get related posts of child term of custom post type
- Limit amount of posts made within a custom taxonomy
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- How to get post type and month/year before while loop for date.php file
- Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish
- Index page with the same id as the slug
- How can I make the slug of the taxonomy also the slug of the custom post
- WordPress custom post type permalink rewrite shows page not found
- Why is my site using index.php instead of archive?
- Using taxonomy term in CPT permalink – Pages 404’s
- list taxonomies from a custom post type
- Display a grid of taxonomy terms at root taxonomy page
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- Custom post type as home page with custom url
- WordPress showing archive.php instead page
- Customize Custom Post Type URL
- How to rewrite url for any specific taxonomy?
- Custom post URL 404 error
- Show child custom post types list inside single parent custom post type
- Programmatically rewriting slug through functions.php but returns 404