Your condition is off and will always be true on category pages due to how logic operators work.
This might be more clear if I write what is happening like this:
is_category() || ( is_tag() && $query->is_main_query() )
Once is_category()
is determined to be true the rest of condition doesn’t matter.
You should be more precise with your logic, along the lines of (brackets matter!):
$query->is_main_query() && ( $query->is_category() || $query->is_tag() )
Related Posts:
- Get category id from post id of a custom post type
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Categories assigned to custom post type not found
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- List all custom post type posts from a given category?
- Restrict categories to a custom post type
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Is there a way to list posts of only a certain category
- Taxonomy structure of Sport site
- Getting all custom posts with a certain category
- get custom post type categories
- How to display recent / random posts by its category
- How to get category image custom post type taxonomy in wordpress?
- Custom post types and permalink
- Query Custom Post Types & category_name?
- How do I get the child category posts from a custom post type?
- Search doesn’t find tags or categories in custom post types
- Return array of categories to php function for current post
- Querying Term Posts in Loop
- Get Post Primary Category
- How to add custom post types to normal category pages
- Add category attribute to custom shortcode
- Linking to the most recent post in a Custom Post Type
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Categories sorting
- How can I make my custom posts appear in their assigned category url?
- Allow user to set custom order to a list of custom taxonomies?
- forming WP_Query for posts of all post types but from specific categories
- wp_list_categories() – current-cat class also inside posts?
- PHP variable not regenerating when publishing multiple posts at the same time
- Problem with displaying posts in the CPT category
- Custom Post Types with a common category for a blog listing
- Post injections into Site Origins Page builder [closed]
- Why is my category template ignoring post type?
- Not sure if I should create multiple custom post type [closed]
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Custom post types and category archive
- How do you create a custom template to display a category with an image and related posts below?
- Categorise Custom Post Types
- Category.php template for custom posts
- Tag page only display 10 posts
- in_category for custom post types
- Archieve.php not loading for custom post type
- Category archive in with conjunction with custom post type is empty
- Custom post types and ‘new WP_Query’
- get_category_link() for custom post type does not include custom slug rewrite?
- Showing custom post type categories in the menu
- Creating Sections for Post Types
- Listing all slugs?
- Assigning a category to a custom post type in WordPress
- category list with cutom post count
- Get category if used in a custom post type
- List categories, subcategories and posts from custom taxonomy and custom post type
- Categories won’t appear on custom post type
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Advanced archive url structure (category, tag and date)
- Displaying taxonomies as category links within sidebar and creating pages for these
- Custom post category name showing empty
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- How to show related posts of category on post within custom posttype
- Sudden 404 pages on product category archives
- Custom Post Types – trying to make “title” display
- Convert category to custom post type
- How can I display a specific category on Front-Page
- Pagination for a cpt filtered with a category
- assign array of category to custom post type
- How to seperate posts by categories?
- How to manage a dynamic multi-level page hierearchy system?
- WooCommerce change
- Custom Post By Category
- Adding categories to custom post type in permalink
- Change custom post type permalink according to category
- I can not call the categories of custom post type
- Custom Post Type is not respecting assigned categories
- Change Custom Post Type to Post + Category
- Help with Travel Guide Setup
- Update Cateogory Taxonomy Count for Attachment Post Type
- Project Category Heading
- Getting Custom post category from Form
- Help with Multi Level Category Archive Page
- How can I generate a list of post-type specific categories?
- Front end page submission form does not attach custom post type
- Best way to structure article and issue relationship for CPT
- Custom Post Type used for FAQs Accordion
- Category slug not showing for Custom Post Type
- Get a list of categories ids
- category page template for custom post type
- Custom Post Type Permalinks with %category%
- Display a custom post type list by taxonomy term
- Stop header code from showing in category page?
- Return Custom Post Type Categories
- Using tax_query to get single post per category
- create category upon saving post and save post in that category
- What Is My Fault With This WP_QUERY ? [ Pagination Problem ]
- Is it possible to make is_category() recursive?
- Can a taxonomy of a custom post type be called ‘category’?
- Categorizing Custom Posts in Bulk Based on Title