Use the save_post hook to check if a post that is being saved is a portfolio page and reset the transient.
add_action( 'save_post', 'reset_portfolio_transient', 10,3 );
function reset_portfolio_transient( $post_id, $post, $update ) {
// Only set for portfolio post_type
if ( 'portfolio' !== get_post_type($post) ) {
return;
}
// delete old tranisent
delete_transient( 'randomizeProfiles' );
// reset your transient
set_portfolio_query_tranisent();
}
set_portfolio_query_tranisent()
being the code you already provided.
If you edit portfolio pages often this is not a great solution. You might want to read the wordpress codex on transients for an alternative.
Related Posts:
- Transient api Caches confused
- Transient pagination not working properly
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- Transient caching for wp query
- How to cache wp_query with pagination using transients?
- Using Transients
- I am officially missing something about transient posts
- Save large WP_Query to transient === false
- Set Transient on CPT
- Resetting post data to previous loop in nested loops
- Is it possible to completely stop WP_Query retrieving posts?
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- get custom post type by tag
- Query Custom Meta Value with Increment
- Identify which loop you are hooking into; primary or secondary?
- Group posts by custom field
- get_posts() seemingly ignoring post_type
- Woocommerce custom loop to show all the products [closed]
- Exclude first 5 posts of specific categories in the main loop
- How to bring specific post to front of wordpress loop?
- How to show the posts of some category first, and then all other
- Pagination stops at page 6
- Paginated HTML Sitemap
- Posts loop with pagination on a single post page
- Why does the_content not work like others for a set post id?
- WP_Query Order by Specific Post ID First
- How to limit total number of posts in wp query loop?
- Using one WP_Query object within the loop of another WP_Query object
- Pagination is broken and I need help fixing it
- how to merge a WPQuery array with a PHP array and use the Loop to Output the result
- How to vary post loop results layout and resume?
- Get a post from other loop each n-posts in the main loop
- Loop returning only 1 result
- WordPress Loop and $post
- posts_per_page not working for first page of pagination
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Excluding pages in WP_query using ACF
- reset to main loop doesnt work
- Some doubts about how the main query and the custom query works in this custom theme?
- Post loop for all taxonomy terms
- Stuck in the query loop
- Only display post if published in last 24 hours?
- Transients with dynamic WP_Query
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Include current post into loop
- How to display the featured image for each post?
- Check for the main query from the template
- Trying to retrieve random post, getting a page
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- has_excerpt() not working inside wp_query
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- Exec wp query in slow motion to avoid memory error?
- Loop 3 posts column wise and continue the loop into same columns
- PHP – Loop custom post type categories within jQuery Tabs
- Check if a post has term inside loop
- How to Order By Two Custom Fields?
- Display specific page (that is child) content on parent page
- Query Taxonomy By Page Title
- How to change the default post type over the loop?
- Query Not working as expected
- Compare “Main” post ID to ID inside wp_query loop
- Paginate pages with dynamic query
- WP_Query loop doen’t work with my custom taxonomy
- Determine if ID is page or post and query the ID
- problem with the loop
- get_children() Archive Template
- Function the_posts_pagination() not compatible with WP_Query arguments
- Populate select list with meta values from all posts of a Custom Post Type
- Prevent Duplicate Post Counted by Query
- show most viewed post
- How to show specify category template for both parent and child category
- Pagination inside the blog page not working
- Woocommerce featured products query no longer working
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- Custom Query Pagination not working on static front page
- query all posts published by certain user id
- get_posts query caching?
- WP_Query doesn’t works inside loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work
- Retrieving category pages from subcategory returns empty sets
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Iterate through ID’s in loop
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- An archive page without post format (just standard post)
- Custom post type archive organized by category
- No content found on page 2 of pagination with 1 post per page
- Pull Instagram images into an existing loop?
- Multiple loop for “featured” items returns wrong posts
- Pagination in custom query not working [duplicate]
- How to write a query-function as a query-shortcode?
- Print post data inside loop using theme content template
- First post outside of loop, homepage only?
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- How to save the results of a query as a php file for an autocomplete search bar