Horje

Your query isn 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 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 be in business.

Aside from that, I see problems with what you're doing ... except that querying the database every time the site is loaded might eventually create performance issues. I'd set up an hourly chron job instead to automate the process ... then it doesn depend on or slow down user traffic.


More Solution
Reffered: https://wordpress.org/