Try this
function set_post_type_for_category_archive_wpse_101930($qry) {
if ($qry->is_main_query() && $qry->is_category()) {
$qry->set('post_type', 'news');
}
}
add_action('pre_get_posts','set_post_type_for_category_archive_wpse_101930');
Related Posts:
- Stop header code from showing in category page?
- 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
- Load custom posts with same tag as page
- Date archives for custom post type
- How to get a list of term names of the custom post type im currently on in single.php
- is_singular won’t call my functions?
- 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
- Return array of categories to php function for current post
- Get Post Primary Category
- Weird problem happening with custom taxonmy when creating/updating posts
- CPT Archive with core Category
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- Get posts from a custom post type by child categories of a parent category
- Custom Post Type Archive Page Filtering
- get the custom post type title/name
- Get parent categories of custom post type
- Custom post type – get_day_link()
- Make a custom_post translatable
- Category.php template for custom posts
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- WP_Query Custom Post Type if Category ID Equals
- Assign category a default post type
- Assigning a category to a custom post type in WordPress
- How do I add custom HTML to the content of an archive page’s posts?
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Archive Template being used instead of Category Template for Custom Post Type
- Advanced archive url structure (category, tag and date)
- How can I increase the post count for custom post types only?
- WordPress sitemap with Custom Post Types
- Show the categories the current post has
- Display all Categories except ones with a specific parent
- 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?
- Custom front-end form for adding post – Category problem
- In the php, how can I have a category of a custom post type display?
- Custom WordPress theme not displaying posts from category
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- Get meta values from parent post and save in child post
- Custom Post By 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?
- can’t see categories in appearance-menu-categories
- Custom Post type archives / categories give 404
- archive.php can’t find categorized posts
- How to call Shortcode categories for custom post types?
- How can I set up the URL for a category archive for a custom post type?
- Categories in custom post types
- is_singular won’t call my functions?
- Add Category names to post lists of custom post type
- How can I list all the categories under a Custom Post Type (taxonomy)?
- Custom Post Type Archives by Date with Custom Permalink
- automatically save custom post type title as a category
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Dynamic Custom Post Type Plugin
- How to filter out post type meta?
- When ‘is_post_type_archive()’ return true?
- How to detect filter in URL in Category page?
- Replace li Items with divs with classes
- showing custom post types of a certain category only
- Query & Order posts by custom fields
- Show a Category X’s custom post type on Category X archive page?
- WordPress showing archive.php instead page
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Configuring a meta query with multiple post types that have the same relationship on a single page
- How to retrieve category of a post in have_post loop?
- Disable custom taxonomy on admin bar
- Assign CPT archive page attributes
- Want a custom query with just one category but from all custom post types
- Custom post type and custom taxonomy 404 on page 2
- Show current user posts in custom post type query
- Custom Post Type with modified permalink structure results in 404
- 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
- redirect after submiting post for review
- Control over custom post types on a specific page
- Duplicate posts in my custom loop
- WordPress loop add heading before first of type
- Meta box not saving
- how to use two permalinks for one custom post type based on categories
- Featured image in custom post is being disabled
- Rewriting archive page slug to be different than custom post type slug
- Custom Catagory not found
- 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
- Custom Post-type not returning the right child_of
- Is there any way of not using my_init_method in the following code (that creates a custom post type)?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- Custom Post Types Permalink