Im trying to programmatically change the status of a page that already exists with a status of 'draft' to 'publish' using a custom function.
I have tried using custom SQL queries and $wpdb to explicitly UPDATE the post status using its ID but this causes errors when retrieving the post again in the future. I have no problem changing a published page to draft, but the reverse doesn't seem to work.
$post = array( 'ID' => $company_page_id, 'post_status' => 'draft' ); wp_update_post($post);
Code above works perfect. My thought was the code below would do the trick, however nothing changes when executed. Are there steps I am missing when changing an existing drafted page to published? Any insight is greatly appreciated. Thank you in advance.
$post = array( 'ID' => $company_page_id, 'post_status' => 'publish' ); wp_update_post($post);