I couldn’t comment, because i dont have the rep
Your code will not update because meta_key
field is not in the wp_post
table.
First, you’ll want to query all posts where the meta_key wpcf-engine-days-to-go
= 0 and then iterate through the post ID’s and make your changes to the wp_posts.
Un-tested Example:
$meta_value = 0;
$results = $wpdb->get_results("SELECT * from wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_posts.post_status="publish"
AND wp_postmeta.meta_key ='wpcf-engine-days-to-go'
AND wp_postmeta.meta_value="".$meta_value .""", ARRAY_A );
foreach($results as $row){
// do update on this POST
$update = $wpdb->update('wp_post',
array('post_status' => 'draft'),
array('ID' => $row['ID'] ),
array(
'%s', // string
),
array( '%d') // id
);
}
}