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
- 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?
- How to force one column layout on custom post type edit page?
- modify all posts of a category to “no comments allowed”
- Custom permalinks – post type – hierarchical taxonomy’s
- Querying Posts by Taxonomy From Alternate Network Site
- 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
- [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
- How to delete all posts from a custom post type?
- Best practice for adding posts in bulk
- Why is my custom loop not filtering correctly nor paginating?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- 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
- 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
- WordPress Orderby Numeric Value Not Working
- Weird problem happening with custom taxonmy when creating/updating posts
- Deleting Custom Post type data using mySQL command
- 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
- Disable block with taxonomies at post page
- 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
- Get related posts of child term of custom post type
- 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?
- WP_Query orderby and tax_query
- Migrating a taxonomy’s tags to the native category
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Number of posts in the archive
- Custom post type menu
- display posts of custom post type with custom taxonomy
- Display Custom Post Types Glossary
- How should I structure complex content hierarchies?
- Different structure/content for posts from a custom post type
- List all posts in taxonomy term
- Custom taxonomy query showing more than 4 posts
- custom taxonomy listing returns no posts
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- How to divide Subcategories into pages of parent category wordpress
- Why is my custom post content only viewable when signed into WordPress?
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Displaying all posts by category and showing content on click
- Right way to store a large set of similar information on website? [duplicate]
- Define multiple prefixes for custom post type
- Limit posts per page depending on the size of a div?
- Display title of all custom posts from same taxonomy term on a custom post template
- Delete Post by User
- How to get all posts related to a taxonomy?
- Filter By Term Not Working – Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- One Post with different content, depending on a Page
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Custom Post Type
- WP_Query for CPT with filter by another WP_Query
- Custom Post Status & Taxonomies
- Linking custom taxonomies and posts
- Query Posts From Multiple Post Types
- how to limit query_post to first page?
- Listing custom post type items from a couple of custom taxonomies
- Inserting two categories
- How to make a template for a specific post of a custom post type?
- Get custom post type parent category
- How to delete unnecessary custom post types in the UI
- Advise on Custom Taxonomies and Structure
- cannot export data from CPT UI (books)
- How to automate the creation of advanced layout article/post
- display posts, pages and custom post types from another wordpress site
- Sort ACF by custom taxonomy