First you will need the slug of the current category:
$cat = get_query_var('cat');
$currentcat = get_category ($cat);
Then you can use the same loop. Just add the following to $query_args
to limit the outcome to the current category:
'category_name' => $currentcat->slug,
Related Posts:
- How to show subcategories using loop?
- Five posts from a category in footer
- How to get all unique categories for posts in loop?
- Check if loop has any categories?
- wp_query is showing posts from other categories
- WP_Query with one category in args shows other categories
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Get categories within specific term
- How to show specify category template for both parent and child category
- Display 3 levels of categories on page
- I have 3 categories, i want to display on a loop the last 3 of every category
- Retrieving category pages from subcategory returns empty sets
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Pagination only showed when no category is set in wp_query
- Get post count of current loop when using multiple queries on one page
- Exclude or Include category ids in WP_Query
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Display products from specific category in shop page
- WP_Query to show post from a category OR custom field
- Use Transient API to cache queries for all posts in all categories?
- Loop inside the loop
- Exclude post on loop by multiple meta key value
- cloning a WP_Query
- How to query ‘posts_per_page’ to display a different blog posts index template?
- How is WP_Query connected to WP_Post in The Loop?
- Query Custom Post by Category
- WP_Query order by date in meta_value
- Get posts for last working week in WP_Query
- Get Category Archive Template Name Dynamically
- How to limit WP_Query to one result on the loop?
- query user display_name failed in a custom mysql query foreach
- Query posts by specific word on title
- Multiple taxonomy And acf filter group by
- Reset postdata to custom query in nested queries
- How to Filter Posts by Custom Fields?
- Filtering posts from different categories into different section by doing WP_Query only once
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Query posts from category A, and from either category B or C
- Loop Split two Columns
- Combining categories (Query posts with multiple taxonomy terms)
- Filtering out child category posts from parent category archive not working
- How to list posts with disabled/closed comments, with pagination?
- How to make a second query offset -2 from current post
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Custom taxonomy.php not working
- Best choice for multiple loop in page?
- WP Query – order posts by meta field first and then order the rest
- Wp_query with 2 meta keys and array of meta values
- category__not_in and id values from variable
- How to create custom query by keyword in post title?
- Create a loop on my pages with new “WP_Query”
- WP_Query Taxonomy categories filtering
- WP ForLoop to compare meta information of posts to determine what post to display
- How to filter query loop block with a search string from the query parameters
- Do not duplicate posts with multiple categories in multiple loops
- Different Loop for tag pages?
- Filtering by multiple conditions in the loop
- More efficient way to list posts by category [duplicate]
- How to access $wp_query object from array of posts given by get_posts?
- 2 queries with counters
- Search.php – return number of results but cannot loop through
- Creating ‘posts page’ loop based on the page itself
- WordPress Queries Not Working?
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Post incorrectly excluded when using “category__in”?
- Use get_cat_ID to retreive multiple category IDs
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- display ACF repater field in archive page
- query hook parse_tax_query function takes no effect
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How to display the category dropdown auto search list when key press?
- Categories In English version showing not canonical URL, instead shows query search result
- Check the stored / cached WP_Query with transients on post change
- New template file does not load category-specific post
- Related posts queries
- Pagination for Category does not work
- Custom query for custom post type not getting correct post ID
- Exclude parent categories from recent posts list
- Query post with content only
- Single query for multiple categories
- Adding Category in WP_Query Not Working
- Why is my query not giving results?
- how to show more than 1 post into three columns query
- display all posts from category with and without terms in chronological order
- Continue loop after $queryObject
- custom query – offset to pagination
- Display Count of posts
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- List ALL posts within last week from current category on category page
- loop through custom post types with meta data
- Using Query In Post Type Archives
- How ‘secure’ are loops?
- Multiple loops on index page with sticky post and pagination
- How to do a loop inside a loop?
- tax_query not working properly with get_posts
- the_excerpt() not working in custom archive
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2