What you seem to be asking is relatively easy with a filter on pre_get_posts
.
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');
That will hijack your entire category archive. That is why I asked if you “want to force your category archives to only show posts from the news post type”. From your response, and your code, it seems like you do.
By doing that, you won’t need the category-%n.php
files at all, just the category.php
file.
Related Posts:
- Archive listing of posts by publish year (multiple years)
- Get posts with at least one category in common with current post?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Add a specific part of current category page url to shortcode
- How do I remove a category from a wordpress loop>
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Multiple Tag Filtering
- Link to index.php from home.php?
- How to filter specific element of an array in wordpress/php?
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Hide empty categories from get_categories
- WordPress categories not working throughout site
- Apply class to every paragraph that holds image?
- Set media upload attachment link to none and hide it in WP v3.5
- How to set custom cookies before output
- Getting key value of WP_Term object in wordpress
- How can I hook into and edit the text of a wp_nav_menu tag?
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- How to make an meta_query optional?
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- How to Remove Parents Category Permalink from Posts
- Looking to exclude blog posts from category Previous/Next buttons
- wp_get_attachment_url filter won’t accept two arguments
- Filter link to existing content suggestion
- How to exclude specific category from the get_the_category(); array
- How to use return in my custom function instead of echo
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- WordPress php filter admin_body_class not working
- Combine two filters into a single call
- combine Code 1 with Code 2
- Handling Body class based on Template
- get post based on category chosen in drop down – The ajax method
- Global variable $post returning incorrect object
- Add a class to the anchor tag on HTML5 gallery
- Proper syntax or method for keeping url in modified isotope / category links
- Show prices with tax in Woocommerce Mini Cart [closed]
- Removing “wpautop” (auto tags) only on certain pages?
- WordPress Gravatar filter is removing my custom attributes
- get_template_part based upon post’s category
- Alert Bar section within WP loop is displaying even though there are no posts
- Different post styles depending on category
- Define specific category name in PHP
- Category title output before opening title tag
- Include Parent Term in wp_list_categories
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Filtering a function’ output for a new continued function
- Deleting Certain terms from appearing on the front end as links
- Add meta tags to a custom header
- Ajax filter button display all posts
- How to get category name or ID by post?
- How to hide posts of a specific custom category in WordPress?
- Add new post in existing categories using wp_insert_post
- Custom query vars filters problem with pagination
- How to change logo by category
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- random display categories – change url
- Get the name of menu item with wp_nav_menu
- Output category list inside array
- update_post_meta() not saving data inside of save-post filter
- How to add aria role and schema markup to custom walker container
- Define category ID using get_post_meta
- Must filter functions receive all arguments passed to them?
- First post article different on Archives template
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Adding wp_list_categories to a specific div that was appended using jQuery
- How to internationalize header image?
- User filter posts by year
- I need to display posts in subcategory beside posts in main category
- Order category posts by last word of custom field
- Variation prices breakdown only for single product page
- Change category thumbnail size
- Displaying the Archive Page’s Name on the Page
- Get nice name of category from slug (remove dashes of category)
- How to use apply_filters() inside a plugin class?
- Get parent category name when only child category is applied to a product
- Polylang and template files
- Show subcategory name selected in specific category woocoommerce
- Custom content using in_category
- Add class to all meta boxes for a custom post type
- How to add custom text near category/tag title in WordPress Twenty Fifteen Theme?
- PHP get_category() function redeclared
- Rearrange get_categories array compared to another array
- Archive page if else not working for post_excerpt and post_content
- Select All not working in a WordPress search filter
- Query seems to be duplicated
- Top menu disapears in Category Pages when filtering using ACF
- !in_array doesnt recognize category
- Remove the_content From Loop
- Stop header code from showing in category page?
- Category List in Theme Options Page
- How to add custom checkout field in user details mail template
- Keeping the previous get value and add another value when submitted
- archive per year with monthly
- For each loop will not append to the_content hook
- Product Category Page in Full Width
- Assign new post author IF another user in custom field on post transition
- How to change wp-admin and wp-login urls