Check the stored / cached WP_Query with transients on post change
Question
right now I have WP_Query stored for 24h (1day) with set_transient function. Everything works fine like it should. But if for example I change the post which is in the stored array to private or modify its meta_value, the post will still be seen on frontend.
Any way to check if the post values have been modified? or I should use some other function for that?
The code:
if (false === ($loop = get_transient('randomizeProfiles'))) {
$loop = new WP_Query(array(
'post_type' => 'portfolio',
'posts_per_page' => 18,
'orderby' => 'rand',
'order' => 'ASC',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
array('key' => 'move_to_archive','compare' => 'NOT EXISTS'),
array('key' => 'move_to_archive', 'value' => '0', 'compare' => '=')
)
));
$hour = carbon_get_theme_option('posts_hours');
$time = 60 * 60 * $hour;
set_transient('randomizeProfiles', $loop, $time);
}
0
cache, loop, private, transient, wp-query
3 years
2020-03-27T12:51:21-05:00
2020-03-27T12:51:21-05:00 0 Answers
113 views
0
Leave an answer