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?
- Custom Post Type Archives by Year & Month?
- WP_Query by a category id and a custom post_type
- Custom Post Type Archives by Date and Taxonomy
- Custom post types – Use post_id in permalink structure when using has_archive => true
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- How to add meta box to backend menu page
- Custom Posts Types using Posts Category
- Change title in head on Archive page
- How to get a list of term names of the custom post type im currently on in single.php
- Custom Permalinks for Custom post Type Archives?
- Pages, Custom Posts & Custom Taxonomy defining slug structure
- How to show a tag archive of one post type only
- Custom taxonomy archive page not working
- On clicking on the category name the page is redirecting on 404 pge
- Hook onto Add New Category
- wrong template for page of archive
- Custom edit post column – category not showing
- How to show multiple post types on taxonomy archive?
- CPT: archive-cpt.php VS custom page template
- Get a permalink structure of /%posttype%/%category%/%postname%
- Display custom post type taxonomies as an archive page
- Change name of custom post type archive
- Editable content on a Custom Archive page
- Pagination on category page with custom post types
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- Get archive post type name
- Show custom post type filtered by category
- Filtering WP_Query
- Custom post type – get_day_link()
- Filter CPT posts by one or more categories
- WP Query with categories only shows one post and ignores the category
- Custom Post Type + Categories
- Hierarchy and access control for Custom Post Types (CPT)
- Loop filtering Custom Post Types and/or Categories
- Custom post type / taxonomy rewrite archive page 2 gives 404
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Custom Post Type Category Link
- How to retrieve category of a post in have_post loop?
- Get parent category id from child category page for custom taxonomy
- How to add current custom taxonomy slug to body class
- Meta data (Tags and Categories) for Custom Posts not showing.
- Custom post types with categories in template
- The Difference Between Categories and Tags and Taxonomies and Terms
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Get assigned post categories
- Default Category Page not showing custom post type which has taxonomy category
- Post Query not working
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- Category Name with Custom Post Type
- Am I mixing up the concept of posts pages and categories?
- CPT archive page – show one post from each taxonomy term
- Event Archive by Month
- how to organize my categories or should I do custom post types for some?
- Order Categories by Hierarchy?
- Multiple categories assigned to a single product breaking the breadcrumb
- How to achieve a multi-taxomony layout with posts?
- Custom front-end form for adding post – Category problem
- Custom Post Type Category Displaying ALL Sub Categories as well
- Control over custom post types on a specific page
- Feature image Gallery made from Custom Post type + Categories
- Get meta values from parent post and save in child post
- Only show current category post
- how to use two permalinks for one custom post type based on categories
- Rewriting archive page slug to be different than custom post type slug
- Site loads very slow for archive custom post type page
- Custom Catagory not found
- Page to show custom posts and one category
- How can I list custom post by custom category?
- how to show perticular category posts in custome page
- Use only selected regular categories for a Custom post form
- Bulk remove category from custom post type?
- Problem with menu categories doubling up when updating database?
- Remove slug from Custom Category Permalink + dual-category permalinks
- How to query posts by category with the_title();
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Custom Post Type posts not getting picked up in archive widgets
- How do I get an intermediary page between 2 custom post types?