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
- Separate archive template to show posts and CPT by same category/taxonomy
- WordPress Custom Post Type Archive, filter by category and get pagination working
- Custom Post Types and archives
- Display Next/Prev when looping Custom post-types archive?
- Search doesn’t find tags or categories in custom post types
- Display custom field of specific post where post title matches variable
- Conditional to modify query results
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Need post_type_archive_title function but in ‘single’
- Display custom post type taxonomies as an archive page
- Custom Post Types and Categories?
- Display CPT description on archive.php pages for all CPT
- Output custom post shortcode. Help spot the error.
- Change name of custom post type archive
- How to count custom post types with conditional operators
- When ‘is_post_type_archive()’ return true?
- Editable content on a Custom Archive page
- Set a default category – if the user didn’t select one- before creating a post
- Get categories and descriptions from custom post type
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Combining custom post type and post category
- Second Custom Post Type Archive
- How to get “custom post type”-archive with working permalink to it?
- Possible for Category Base and Custom post Type to share the same slug/permalink?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- GravityForm: Populate Dropdown with custom post type [closed]
- Link users to a custom post type
- Create a random unique 6 digit number as custom field for custom post type
- How to output wordpress custom tags separated by comma?
- Multiple custom post type loops in category.php
- Loading all files within a directory
- Querying Term Posts in Loop
- Blog page showing same content as homepage
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- How to create new category for custom post type?
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- Get rewrite slug of custom post type in template
- Show Different Header on a Specific Post ID
- How to show the archive / post type description on Single templates
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Add category in post type dynamically
- is_main_query() not working for WP REST API