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
- get term archive url / link
- How to get the custom post type from an archive page?
- Hide/Show only specific categories in wp-admin new-post.php
- How do I redirect all 404 errors of a specific post type to another URL?
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- How to save the checked boxes?
- Custom Post Type, Two categories, Two columns with Pagination
- How to get only one category of custom post type?
- Append taxonomy terms as class names in markup?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- GravityForm: Populate Dropdown with custom post type [closed]
- Group posts by custom post type
- I need to add endpoint for wordpress categories
- Can’t remove front from permalinks for custom taxonomy category page
- Pre-selecting the category for a custom post type
- Use “archive” as slug for custom post type
- WP the_posts() on single-cars.php get category link
- Understanding Post Formats/Custom Post types Etc
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Return the name of the post type
- archive as a page, so that it can be added in the wp_menu_nav
- Displaying Custom Posts
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Include custom post type custom taxonomies in Categories widget
- Different post title, keywords and description
- WordPress custom post categories and subcategories on category.php
- post_content is stripping HTML when adding a new post? [closed]
- Querying a custom post type, but not show duplicates
- Dynamic category name in query post
- Retrieve Custom Taxonomies with Description and Slug
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- How to set “section categories”?
- Custom Post Type has wrong label and is not found when called by a loop
- Having issue on Loading Meta Data From CSV to CPT
- Rewrite URL of Specific Post of Custom Type
- Page + Custom Post Type with same category
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Can’t seem to filter wp_query by current category ID
- Return all wordpress custom posts in specific multidimensional array
- Custom Portfolio String
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- how to display custom taxonomies in front page
- Remove date rewrite rule for custom post type archive page
- How do I edit this code so that it also adds specific meta data into the user and subsequent CPT being created?