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
- Paginate pages with dynamic query
- WP_Query loop doen’t work with my custom taxonomy
- Advise on Templates for Custom Queries
- Search.php – return number of results but cannot loop through
- How do I get the content of a custom instance of WP_Query?
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Creating ‘posts page’ loop based on the page itself
- Why does apply_filters behave different inside and outside a loop?
- WordPress Queries Not Working?
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Filter subpages in while loop from WP Query object
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Custom query does not find pages
- Query WP Page for Buddypress Group Home [closed]
- How to sort by most watched in X days/months
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- $post in wp_query?
- WP Query get only 1 post (sticky, not sticky etc)
- WP_Query not returning correct result with meta_query parameter
- How to pass the current content of $wp_query to a new page?
- How to make the ‘request’ filter work?
- problem with the loop
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- get_children() Archive Template
- Function the_posts_pagination() not compatible with WP_Query arguments
- How to separate two columns from one content on a page template?
- How can I use arrays and a foreach to generate many lists with WP_Query?
- How to use custom page for all posts with custom url, call another directory?
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- display ACF repater field in archive page
- Populate select list with meta values from all posts of a Custom Post Type
- Prevent Duplicate Post Counted by Query
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Duplice post with standard WP loop – fixed by using query_posts() instead
- WP_Query breaking the loop in a nested loop
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- Can I alter the main loop to ‘orderby’ a custom callback?
- show most viewed post
- How do I stop the same post showing multiple times in a archive?
- New template file does not load category-specific post
- Show a message if there are no active posts in category
- Show custom content when loop or wp query reaches specific time?
- Bootstrap grid while loop
- Related posts queries
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Get categories within specific term
- Avoid removing duplicate posts
- Loop through array of pages
- How to show specify category template for both parent and child category
- Pagination inside the blog page not working
- Custom query for custom post type not getting correct post ID
- Woocommerce featured products query no longer working
- how to get custom attachment url?
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- How can I use WP_Query to sort ‘event’ custom post type by date?
- Query post with content only
- Problem with my loops
- Display posts side by side with custom query
- Custom Query Pagination not working on static front page
- WP_Query & Duplicate entries
- Regarding a custom loop and output HTML tags
- Repeat array inside array through while loop
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- What’s causing an infinite loop?
- display the children of the post using the current page as the main parent
- Display 3 levels of categories on page
- update_post_meta() not updating
- Paging works correctly on local version, but not live?
- query all posts published by certain user id
- pages shortcode filtering by category
- the_post_thumbnail and multiple WP_Query
- I have 3 categories, i want to display on a loop the last 3 of every category
- get_posts query caching?
- Custom post type loop error: Trying to get property of non-object
- Second WP_Query loop shows data from main query
- Meta Query if Values Don’t Exist
- Get post Number with local loop and template
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Why is my query not giving results?
- Hi , i am trying to set the post for 24 hours and with it will be changed
- why default wordpress loop not working outside index.php
- how to show more than 1 post into three columns query
- WP_Query doesn’t works inside loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Display three sequential posts on each page load, without repeating previous
- Calling a function with WP_Query only ever brings the first result
- View related categories in order of posts
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work