How to Set Post Status to Draft if older than today
Your query isn’t giving you a post ID, it’s giving you an entire post. The SELECT * returns all columns, ID, post_status, etc. So setting $my_post[‘ID’] = $a doesn’t do anything for you in this case. Try using: $my_post[‘id’] = $a->ID; instead. That should accurately set your ID before you call wp_update_post() and you should … Read more