This:
if (is_tag()){
will be true for any query on a tag archive page, including the query WordPress makes to load menu items.
You want to check if the current query is both the main query and tag query:
if ($query->is_main_query() && $query->is_tag()){
Related Posts:
- Which Template Page Should I Use?
- How can I create an automatic drop down menu with my tags?
- page menu entry for custom post type
- How to display custom WP menus?
- Custom post type archive page blank
- Cross reference custom post types
- Is there a way to establish parent/child relationship in WP menu links exclusively?
- How to get all tags of a custom post type by id
- Use custom walker to add taxonomy terms to main nav menu
- A page that shows a list of a specific custom post type
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Single custom post type’s menu ancestor/parent is Posts archive page
- menu link to custom post_type?
- Review site custom post type structure
- Custom Post Types in the WordPress Navigation Menu
- My archive-posttype.php template is not loading
- Custom Post Archive is not working
- Show all tags on custom post type
- Best way to specify “article type” in URL
- Tag page only display 10 posts
- data-type=”” … needed post tags stripped of characters
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Dynamically output a class to an anchor tag depending on what tag is chosen
- Ordering Submenu Pages in WP 3.1
- Including link to custom post type in ‘wp_list_pages’ function
- Creating tags via API
- How to display custom post type tags?
- Display custom post types in wp_list_pages
- Display posts with tag for custom post type only
- How can i automatically add CPT single pages as sub menu items
- How can I use archive-{post_type}.php theme template?
- Meta data (Tags and Categories) for Custom Posts not showing.
- get_the_tag_list() returns bad links
- Custom Post Type Link added to menu won’t show in frontend
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Tags not working in my custom post type
- How to list tags from custom post type attachments?
- Strip Characters From Tag Name
- How To Display A List Of CPT Posts In A Meta Box On Menus Page?
- Why does my taxonomy have a category style div id?
- Get custom post type categories to show up in menus
- portfolio custom type tags support
- show current item in custom menu, when inside a custom post type
- Need help deciding on a taxonomy
- WordPress menu with custom taxonomy
- Prevent custom post type from showing up in custom menus
- display custom taxonomies limited to custom post type?
- How to integrate single and archive templates for custom post type in any WordPress theme
- Get Posts by Category, Tag , and CPT Taxonomy
- Is it possible to have “two” sets of tags?
- WordPress admin display post type tags as checkbox
- The Difference Between Categories and Tags and Taxonomies and Terms
- Show all Tags in each post
- Custom post type permalink uses archive page to display posts
- wp_get_canonical_url showing first url of the post for custom page
- Taxonomy template page not working
- Print all the tags from a custom post type
- 404 Page Not Found on /Page/2/ on Tag Page
- How to constrain the results to a specific post_type on tag archive page?
- Custom Post Type – Portfolio no longer works
- CPT with its own category and tag url
- Custom Post Type Archive template not being called
- Default post_tag for custom post type
- Can’t replace the default sidebar with a custom sidebar on Custom Post Type in Genesis
- Custom posts – tag pagination
- add custom tags for custom post type in wordpress
- How to Display the tag content of Custom Post?
- How to programmatically add elements in a custom menu
- Custom post type tags not showing in search
- Issue with Custom Post Type Tags
- If tag exists, then echo once
- Custom post type, taxonomy and admin bar
- Custom Posttype and menu classes
- highlight parent page menu item when in custom post type
- How do I override the default number of items to be listed on an archive.php page? [duplicate]
- display custom portfolio tags
- Advanced archive url structure (category, tag and date)
- Tag template not returning posts [closed]
- Custom post type post in custom menu
- Custom post type posts wont show in wp_nav_menu()
- One post auto attached to many another items
- Navigate by Tags inside a custom Post Type
- Best way for a plugin to define a custom post type archive template?
- Why doesnt my tag page populate with this custom post type?
- Home page is getting current-menu-item even if it’s not home
- Placing Admin Post Metaboxes in Tabs
- Is possible register two archive pages for single custom post type?
- Menu for taxonomies and posts belongs to taxonomy
- Archive page of CPT’s custom Taxonomy
- Pagination links for custom post type shows correct number of links, but links result in Page not found
- How can I put content before my custom post type default pages?
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Search CPT by tag ids
- Finding the CPT archive template source
- build child and anchestor three from post parent
- get taxonomies from terms
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- wordpress get menu id by custom post_type?
- How to set “section categories”?
- Tags being removed upon updates to related posts: ACF/Genesis/WP5.4.1