You’re saving every query object for each category to the same transient. Because this happens fast and time frame is one day, you’re always getting the query object for the first category back. Make your transient name variable with the category, e.g. like this:
$query_category_posts = get_transient('cached_posts_' . $category );
Of course you then need to get the transient with the variable name.
Related Posts:
- Minimize database queries to user tables?
- Redirect to another page using contact form 7? [closed]
- Combine results of multiple WP_Query to resemble single WP_Query
- How do I turn these values from MYSQL into an array
- Related Posts Excluding Certain Categories
- Using multiple variables to assign categories to an array
- What code to use in an array to call the current sub-category?
- Query for posts belonging to multiple categories
- Exclude or Include category ids in WP_Query
- Inject post (from specific category) between posts in Loop
- How to query only for products with status “in stock” in WooCommerce? [closed]
- WP_Query to show post from a category OR custom field
- get_posts with multiple categories
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- What kind of object type is WP_Query?
- ajax category filter
- How can I save an array from a random post sequence for later use?
- Display recent posts from the same category as current post in sidebar
- Getting an array out of WPQuery
- How to filter by category in REST API, excluding posts also in other category term?
- retrieve thumbnail from post ID of best selling product in category
- Counting number of posts with Category B in Category A
- How to order category.php loop by ‘meta_value’?
- assign 2 $args to one wp_query
- How can I display recent posts from a particular category in my header?
- Sorting Posts by custom field
- WP Meta Query for some meta (array) values
- meta_query with array as value
- Show list of authors with latest post NOT older than a month
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- Placing a div or img in between a post array using WP Query [closed]
- Show one post per author and limit query to 8 posts
- WP Query with multiple categories – passing an array works?
- How can i get the last post from wp multisite?
- WP_Query Performance Issues with meta_query
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- wp_query display posts from same category of the post
- List of the years with posts presented
- Set Transient does nothing
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Remove a specific category ID from related post
- How to use transient in this code for related post?
- Complex Category selection as per user input
- Show all post for a given category
- Store sticky post’s ids in a transient
- Five posts from a category in footer
- only delete post within query / for each statement (front end)
- Adding an array from a query string to a WP meta_query
- How to get all unique categories for posts in loop?
- Display Featured Post by Categories and Avoid duplicated posts
- How to use $query->set with post__in?
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- category query for pages not working
- Weird orderby => post__in issue
- Can we return all category (not post) with Custom Query Filter? [closed]
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Query posts intersecting tags and categories
- Query posts from category A, and from either category B or C
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- Exclude posts based on meta value
- Transient not behaving as expected
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Combining categories (Query posts with multiple taxonomy terms)
- Check if loop has any categories?
- Filtering out child category posts from parent category archive not working
- Exclude Category filter from Portfolio section
- Stuck in the query loop
- Query all posts if multiple meta key don’t exist
- Get posts by list of post IDs ordered by those IDs?
- Inserting HTML to close and open divs in WP_Query loops
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Transients with dynamic WP_Query
- How to cache wp_query with pagination using transients?
- Create menu locations for each category in wordpress
- Removing duplicate values between two wordpress queries
- Transient api Caches confused
- Include current post into loop
- Finding WordPress Posts assigned to multiple categories
- Include posts from some categories while excluding from others
- How to array only one key from another array
- Assign custom parameter to each post in query
- WP_Query Custom Post Type if Category ID Equals
- What is the best way (regarding performance) to set transients for logged in users?
- Does meta_value (array) work with ‘orderby’?
- WordPress Custom Search Form Displaying Unexpected Results
- Get categories names as an array to use it in theme settings
- Use premade array as categories in wp_query?
- search serialised meta_value for date value?
- Combine 2 arrays in a query parameter
- How to get the last category name of a child category?
- wp_query is showing posts from other categories
- Using Transients
- WP_Query Taxonomy categories filtering
- Hide products in uncategorized category from search results
- How to load a script code only in posts?
- How do I show related posts from categories instead of tags?