First, I would recommend making this change in Category.php file, as archive.php is affecting tags as well as other archives according to WordPress Theme Hierarchy file system.
Try adding the two queries like next:
$cats = get_the_category();
$cat_id = $cats[0]->term_id;
// news
$args = array(
'post_type' => 'news',
'posts_per_page' => 5,
'cat' => $cat_id,
);
$query = new WP_Query($args);
if($query->have_posts() ) :
while( $query->have_posts() ) :
$query->the_post();
endwhile;
endif;
wp_reset_postdata();
// articles
$args = array(
'post_type' => 'articles',
'posts_per_page' => 5,
'cat' => $cat_id,
);
$query = new WP_Query($args);
if($query->have_posts() ) :
while( $query->have_posts() ) :
$query->the_post();
endwhile;
endif;
wp_reset_postdata();
Related Posts:
- Showing current taxonomy terms
- automatically create taxonomy with same name as post title
- List custom taxonomy specific to one custom post type
- Meta query for custom post type ignored in main query
- How do I move/order posts with a tag to the end?
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- Query Only Show Text on Posts With Certain Taxonomy Tag
- How to develop Knowledge center in WordPress Website
- ACF – Tags not showing up in Custom Post Types
- What does this PHP function code mean? [closed]
- Restrict custom post type to only site administrator role
- Get the ID of the latest post
- How do I append multiple taxonomies to the URL?
- Linking Two Post Types
- How to force one column layout on custom post type edit page?
- Custom Taxonomy with Custom Post Type Finds No Posts
- Get custom post type by category in a page template
- Associating an “author” with a custom taxonomy
- WP_List_Table Inside Metabox Not Working on Submit
- modify all posts of a category to “no comments allowed”
- TV Show database – Best way for structuring it?
- Why is the »_builtin« parameter not advised in »register_post_type()« for custom post types?
- Correct way to use a form to to filter custom posts by taxonomy terms?
- Custom permalinks – post type – hierarchical taxonomy’s
- SQL to update custom post taxonomies
- Query multiple taxonomy in Custom Post Type
- Querying Posts by Taxonomy From Alternate Network Site
- Query posts by custom post type and custom taxonomy
- Custom Taxonomy conditionals
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- saving custom post type data to different table in wordpress
- Query post types with multiple keys
- [Plugin: Posts 2 Posts] Changing display order of connections
- same archive template for different custom post
- Display taxonomy term only if there’s a value
- Include different loop templates in search query
- Adding Custom Taxonomy to WordPress default Post type
- After deleting a post are terms, and custom meta deleted?
- Get all posts WHERE custom_field is LIKE value
- Get the post children count of a post
- How to delete all posts from a custom post type?
- Best practice for adding posts in bulk
- WP 3.1 getting tax_query to work in query_posts()
- Programmatically adding posts
- Keep main articles and author blogs seprerate, News / Magazine like site
- Why is my custom loop not filtering correctly nor paginating?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Making pages also serve as taxonomies? Or give full pages to taxonomies?
- Custom post types with custom directories
- WP_Query search posts by custom post type and custom taxonomy
- get_queried_object error How to show post count by month in the taxonomy page
- Check Title Unique Or Not and If not error message and dont save
- Remove All, Published and Trashed Post Views in Custom Post Type
- How to customize admin posts based on the user who is logged in
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Is it possible to create a shortcode that will query a post based on taxonomies?
- How to post twitter like updates on wordpress
- How to filter custom taxonomy categories on archive?
- How to create an advanced filter search?
- Querying Term Posts in Loop
- apply filters only to specific post listing without check the url parameters
- Custom post type and body_class: Remove “blog” class
- WordPress Orderby Numeric Value Not Working
- Weird problem happening with custom taxonmy when creating/updating posts
- Deleting Custom Post type data using mySQL command
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Am unable to reset a query properly
- Display only one post each WEEK
- Get next and previous 3 posts in a term in single post page
- Making certain categories of CPT not publicly queryable
- Missing Posts in Custom Taxonomy List
- Search / Filter posts on Title/Content OR Tags
- Disable block with taxonomies at post page
- Get parse_query filter to return slug instead of id
- Which post does a taxonomy term belongs to?
- A question on creating filters for custom posts using taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- WordPress sort search results by custom order
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Hide parent categories when clicked, and show it’s childs
- Get related posts of child term of custom post type
- Show titles, date of all posts on single category page
- How to start a new post with custom Taxonomies already set?
- Specific query for custom post type
- Update postmeta Parent when post_status child change
- Display post content with respect to its title?
- First custom field value (out of several) displayed twice after query
- Prioritize posts in query by meta keys?
- Allow users to create posts without logging in?
- How to add attributes to taxonomies that may be different from post to post?
- WP_Query orderby and tax_query
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Migrating a taxonomy’s tags to the native category
- How to produce a sub-page-system in WordPress
- How to sort posts in a custom post type by title in ascending order by default?
- WP the_posts() on single-cars.php get category link
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Number of posts in the archive