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
- Display featured posts first, then display all others within a specific category in WordPress
- Prevent publishing of uncategorized posts
- Global variable $post returning incorrect object
- Custom filter in admin edit custom post type responding with invalid post type?
- Add a class to the anchor tag on HTML5 gallery
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Creating a related post section based on similar categories
- Input type search in Menu
- Swapping wp_dropdown_categories function with wp_category_checklist
- add_action shortcut?
- Is it acceptable to treat a filter like an action?
- Proper syntax or method for keeping url in modified isotope / category links
- Show full posts in archive
- Getting the author name on author archive page
- Filter Select results based on selection
- How can I remove a function that has been added to wordpress with add_filter?
- Issue adding sub category programmatically
- How to control WordPress image metadata (using Imagick)?
- Edit incorrect password message WordPress
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Show prices with tax in Woocommerce Mini Cart [closed]
- Ajax category filtering products default show all
- How to exclude category ID from Looper in WordPress
- how do I get a specific post from a post with a subcategory in WP
- Why does my callback function not work with this custom filter hook?
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Removing “wpautop” (auto tags) only on certain pages?
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- Add filter when image is uploaded?
- Remove the first 5 characters of the_title and orderby that
- Remove a div from RSS feed
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- selected option if current category is the value
- Unique icons next to each WordPress menu item
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- Change tinyMCE editor to allow marked content when pasting from Word
- wordpress archive a user
- Problem with login form
- How to show only subcategories in parent category not parent category?
- how to show only specific category for a template
- Redirect to another page using contact form 7? [closed]
- Alter required message using comment form api
- How to debug this search & replace strings snippet?
- Hide Featured Image Meta Box on Editor Screen
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Display most popular posts of category
- Add filter multiple times using only one master function
- Creating sub-categories via php
- How to edit php code in WordPress Post file?
- Change page title from page using php via php executed from page/post itself
- Define specific category name in PHP
- How to make modifications only to certain elements of an HTML string on the server-side?
- Override a function defined in wp-includes/comment-template.php
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to array only one key from another array
- 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
- Get all categories post is not in
- Get latest post from all categories except one
- Using Shortcode to Grab Archive Listing, Separate by Year
- Displaying posts based on category
- Deleting Certain terms from appearing on the front end as links
- Content filter won’t work