I have a custom php loop/function written that works in the following way
$start = strtotime(date("Y-m-d H:i:s", strtotime("+5 hours")));
$end = get_post_meta( $post->ID, '_limited_dates_to', true );
$remaining = $end - $start;
if ($end > $start) {
wp_set_post_terms( $post->ID, 'not active', 'product_tag', false );
} else {
wp_set_post_terms( $post->ID, 'active', 'product_tag', false );
}
Currently the loop works fine but it is attached with a timer as one can see easily in $start
and $end
.
Now what I am trying to get here is something of a product expiry thing going on. I need the cron to work this if & else loop and automatically set the active or not active tags.
How can this be achieved?
Currently I have to manually refresh the page so that the loop runs.