You are passing the same arguments to retrieve every set of posts. You have alter the arguments dynamically to reflect the current category.
$categories = get_categories($catArgs);
if($categories){
foreach($categories as $category) {
$postArgs['cat'] = $category->cat_ID;
$my_query = new WP_Query($postArgs);
// ...
Untested, and I am away from my dev server but that should be pretty close. You will have overlap for recent posts if several show up in multiple categories and I would suggest passing an ignore_sticky_posts
argument to WP_Query
as well.
Related Posts:
- How can I custom order the results from wp_list_categories?
- wp_list_categories: get latest featured_image of category
- Exclude category by slug for for each loop
- Display page of custom posts?
- Showing current subcategory
- Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?
- Publish Categories for a particular Author on a given Post
- Category ID returns as ‘0’?
- Three Column Loop
- Exclude category from get_the_category
- Display all categories as plain text
- loop inside a loop : search for posts in the same category
- Show all child categories associated to post ID within loop
- Secondary loop cuts off at 10 posts?
- My custom query not detecting the correct category
- Show last post from multiple categories using wp_list_categories
- loop mix my child-category and parent-category
- Get the children of the parent category
- How do I get the category URL from get_the_category?
- How to show list of posts by author and category?
- Default WP Gallery – show only galleries of a certain category
- How do I get the attributes of a short code from a post?
- How to order category.php loop by ‘meta_value’?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- Show scheduled posts in archive page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- add_filter() doesn’t work in loop
- The Loop in Static Page
- Content/Excerpt length control for a specific loop?
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Why we use if with while loop?
- Loop posts only excluding first post
- Loop repeating design pattern
- Sort Posts By Category?
- Can’t access login screen, wp-login.php 404’s
- Create a loop that gets pages with their template
- Query posts if meta key starts with
- 3 Posts in Loop, Show Stickies First
- Loop within a loop (Again) for template
- How to use current_post to open a new unordered list every five posts
- Why cant you place the Loop outside of the index.php?
- sticky post in custom loop
- Rating system and changing the loop
- Ajax Button to load more Posts into a timeline
- How to target thumbnails of the first post in the loop
- Multiple Loops on category.php with pagination on last loop
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Problem getting current post tags to show in a widget
- PHP if post is already displayed, then
- How to style first post differently with ‘get_template_part’?
- Include multiple page ids in loop
- in Foreach Loop the Description is not showing?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- How to append a query string to pagination?
- Pagination on category.php and tag.php not working
- Moving wordpress to different url/server creates redirect loop
- Pulling in featured image into default recent posts widget
- Random post link generator messes up the loop
- Modify loop output for a specific list of categories
- WP_Query of Category Not Showing First Post
- Print the whole page?
- multiple values in an array for category__and does not work with WP_Query
- Pagination for two loops
- Loop info in jquery Tabs – loop into a variable?
- How to get posts using category slug in ClassiPress?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Insert content above an embedded video inside Wordress’ php the_content
- Loop only shows first two posts
- Custom WordPress theme not displaying posts from category
- the loop printing post in one grid
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- WP update_post_meta link loop
- WordPress Numeric Pagination with Query String [duplicate]
- Printing direct descendants of a category with WP_Query
- query_posts ignores the argument
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- show posts from one category with comments only
- Categories and page filtering with pre_get_posts
- Exclude Authors based off date of last post
- Loop from another WP site onto mine
- Having issue with WordPress loop
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop
- Hook in the loop after the first post