I don’t think this is a plugin conflict either.
I have this happening on 3 different sites, which have different versions of WordPress and Job Manager installed, as well as different plugins…
I do have a CRON job running, to check whether the job should still be “featured”, although this code has been in place for quite a while with no issues.
/* Cron job to check whether job still needs to be featured */
add_action('my_daily_event', 'do_this_daily');
function my_activation() {
if( !wp_next_scheduled( 'my_daily_event' )) {
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'my_daily_event');
}
}
add_action('wp', 'my_activation');
function do_this_daily() {
global $wpdb;
$results = $wpdb->get_results(
"SELECT ID, post_date_gmt
FROM wp_posts
WHERE post_type = 'job_listing'"
);
$jobdates = array();
foreach($results as $oneitem) {
$jobdates[$oneitem->ID]=$oneitem->post_date_gmt;
}
foreach($jobdates as $key => $value) {
$postdate = $value;
$id = $key;
$today = time();
$postdate = strtotime($postdate);
$difference = round(abs($today-$postdate)/60/60);
if($difference > 72) {
$wpdb->query( $wpdb->prepare(
"UPDATE $wpdb->postmeta
SET meta_value = replace(meta_value, '1', '0')
WHERE meta_key = '_featured'
AND post_id = %d", $id ));
WP_Job_Manager_Cache_Helper::get_transient_version( 'get_job_listings', true );
}
}
}
-
This reply was modified 7 years, 6 months ago by
ouegy.