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?
- Exclude or Include category ids in WP_Query
- assign 2 $args to one wp_query
- Placing a div or img in between a post array using WP Query [closed]
- 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?
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Count total number of post in foreach loop
- How do I dynamically generate args for wp_query?
- How can I pick a single post from the latest 3?
- List of the years with posts presented
- Set Transient does nothing
- How to use $query->set with post__in?
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Weird orderby => post__in issue
- Can we return all category (not post) with Custom Query Filter? [closed]
- Query posts from category A, and from either category B or C
- Exclude posts based on meta value
- Combining categories (Query posts with multiple taxonomy terms)
- Filtering out child category posts from parent category archive not working
- Exclude Category filter from Portfolio section
- Get posts by list of post IDs ordered by those IDs?
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Include posts from some categories while excluding from others
- How to array only one key from another array
- WP_Query Custom Post Type if Category ID Equals
- What is the best way (regarding performance) to set transients for logged in users?
- Combine 2 arrays in a query parameter
- Hide products in uncategorized category from search results
- Get all posts as an array ID => Name
- How to hide posts of a specific custom category in WordPress?
- How to echo woocommerce category name
- How can I comment comma-separated array values?
- construct complex queries with WP User Query
- Output category list inside array
- Do not duplicate posts with multiple categories in multiple loops
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How order posts from category by date and comment count?
- Get a list of ACF Repeater-Fields as array
- How to get specific string in explode array?
- How to avoid filling up an array each time I run a WP_query?
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Remove from array in WP_Query loop
- Filter sub-category from checkbox form
- `offset` WP_Query argument dont work via `pre_get_posts`
- Use get_cat_ID to retreive multiple category IDs
- Function the_posts_pagination() not compatible with WP_Query arguments
- adding pagination to a foreach loop in wordpress
- Sending simple variable on single page to WP JSON
- Combine relationship posts with existing wp_query
- in_array not working on dev server but works on localhost
- sanitize_post() is not sanitizing Post Object
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- Save large WP_Query to transient === false
- 3 posts from each existing category on one page
- How to display the category dropdown auto search list when key press?
- Check the stored / cached WP_Query with transients on post change
- Get categories within specific term
- WP_User_Query Orderby Not Working
- Loop through array of pages
- How to show specify category template for both parent and child category
- Exclude parent categories from recent posts list
- How to filter specific element of an array in wordpress/php?
- Check the product in the cart from which category is and show message
- Multiple values in WP_Query : category__and
- How to exclude posts by ID within a category/archive loop
- I have 3 categories, i want to display on a loop the last 3 of every category
- Adding Category in WP_Query Not Working
- display all posts from category with and without terms in chronological order
- Pull posts from all categories if quantity is not met?
- Retrieving category pages from subcategory returns empty sets
- WP_Query: Meta_Query with serialized value (or a workaround)
- how to query for meta_value have array
- Display Count of posts
- Iterate through ID’s in loop
- foreach,having wp_query inside, breaks after showing one result
- Custom post type archive organized by category
- Query seems to be duplicated
- !in_array doesnt recognize category
- Dynamically name array in WordPress loop – add/get values
- Dynamically create array from page title
- WordPress Query Returning Every Post
- Creating Custom Query
- query_posts problem – need help
- Fix incorrect related posts code snippet
- List categories using WP_Query
- I want to place a post before all others from an ACF boleen field
- Advanced Search – Is this possible?
- wp_query, calculate with two dates when ‘key’ is text format
- Pagination only showed when no category is set in wp_query
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2