Add to $post_type
array, don’t replace it…
function dog_query_post_type($query) {
if( is_category() && $query->is_main_query() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type[] = 'dog';
else
$post_type = array( 'post', 'dog', 'nav_menu_item');
$query->set('post_type',$post_type);
return $query;
}
}
add_filter('pre_get_posts', 'dog_query_post_type');
Related Posts:
- Filtering a custom post type by custom taxonomy in archive template
- Why are posts from custom post type not displayed in “category” archive?
- Displaying category archive of custom post types
- Regex problem in an add_rewrite_rule
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Category page only displaying the posts from a custom type
- custom taxonomy archive by year
- CPT Archive with core Category
- Custom Post Type Archive Page Filtering
- Archieve.php not loading for custom post type
- Archive Template being used instead of Category Template for Custom Post Type
- Menu’s breaking, now showing all page links on site
- Advanced archive url structure (category, tag and date)
- Display all Categories except ones with a specific parent
- Custom WordPress theme not displaying posts from category
- Adding Custom Post Types to category/tag/author archives breaks header content
- Custom category taxonomy – archive page not showing up
- How can I generate a list of post-type specific categories?
- Custom Post type archives / categories give 404
- archive.php can’t find categorized posts
- How can I set up the URL for a category archive for a custom post type?
- Categories in custom post types
- Stop header code from showing in category page?
- Separate archive template to show posts and CPT by same category/taxonomy
- WordPress Custom Post Type Archive, filter by category and get pagination working
- Can’t remove front from permalinks for custom taxonomy category page
- How to get categories linked in posts for a specific post type
- Why is my site using index.php instead of archive?
- Custom post type, organized by categories
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- WordPress showing archive.php instead page
- Remove CPT name from permalink but add %category% instead
- Set a checkmark in a category based on a URL-parameter
- WP Query with categories only shows one post and ignores the category
- Custom post type archive page blank
- Adding custom post type to count in category
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Custom Post Type and Category Base Rewrite Issue
- Get the category from custom post type
- Post injections into Site Origins Page builder [closed]
- Custom Post Type + Categories
- How to create a gallery page with categories?
- Custom Post Slug same as Parents Category Slug
- WordPress posts page for customer filtering and sorting along with category filter
- Custom archive page for CPT UI
- I am having Trouble to get list of Categories of Custom post Type
- Hierarchy and access control for Custom Post Types (CPT)
- Multiple (two) category postings on the same page.
- Loop filtering Custom Post Types and/or Categories
- How to display custom post in archive section of the wordpress page?
- School & class blogs: Categorize with categories or custom posts?
- Custom post type and category link together
- Why is my category template ignoring post type?
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- The loop seems stuck to a single (now deleted) post
- Not sure if I should create multiple custom post type [closed]
- Cross reference custom post types
- Make a custom_post translatable
- Pre-selecting the category for a custom post type
- Use “archive” as slug for custom post type
- Custom post type / taxonomy rewrite archive page 2 gives 404
- browse by category and tags?
- Archive for CPT
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Categories filtering in new post
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Is it better to use filter for the_content in archive pages?
- Custom post types and category archive
- List of Posts and Categories
- How can I show 1 featured post in a styled element, and the next few below differently styled
- How do you create a custom template to display a category with an image and related posts below?
- How can I list Custom Post Types created with the Types plugin under categories?
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- How can I get this request to use the Custom Post Type page template instead?
- Custom post type posts don’t show in archive widget
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Custom templates for a specific category
- Archive for a Taxonomy of a Custom Post type
- CPT category hierarchy
- Categorise Custom Post Types
- WP the_posts() on single-cars.php get category link
- Category.php template for custom posts
- How to retrieve category of a post in have_post loop?
- Categories and tags for custom post types
- Create new custom post and post category of same name
- Archive not sorting correctly
- Tag page only display 10 posts
- category page for custom post type
- in_category for custom post types
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- What’s the name of the custom post type yearly archive template?
- Get parent category id from child category page for custom taxonomy
- how to remove pages loading with the archive templates
- Getting used tags per post type
- Custom Post type & Taxonomy 404
- Category archive in with conjunction with custom post type is empty