get_posts returns no results when run via wp-cron
-
I have a get_posts that I need to run regularly as part of a wp-cron triggered function – it works as expected if I call the function via a shortcode, but produces no results if triggered via wp-cron (though logging shows that the rest of the function is executed normally through to the end).
Can anyone think of a reason this should be the case?
// Setup arguments for topic query $topic_args = array( 'post_type' => bbp_get_topic_post_type(), // Only bbPress topic type 'posts_per_page' => -1, // All topics 'meta_key' => '_bbp_last_active_time', 'fields' => 'ids', 'orderby' => 'meta_value', // Order by _bbp_last_active_time (ie. from newest to oldest) 'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ), // All public statuses 'meta_query' => array( array( 'key' => '_bbp_last_active_time', 'value' => date($current_time, $day_ago_time), 'compare' => '>', 'type' => 'DATETIME', ) ) ); $topics = get_posts( $topic_args ); if ( $topics ) { // This code block is never executed if the function is run via cron
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_posts returns no results when run via wp-cron’ is closed to new replies.