wp_insert_post block php script execution
Hi all, I'm working on a plugin that calls wp_insert_post(), but the plugin's execution is locked in a call to wp_insert_post().
Here's the code snippet I'm running:
$new_page = array(
'post_type' => 'post',
'post_title' => 'Test Page Title',
'post_content' => 'Test Page Content',
'post_status' => 'draft',
'post_author' => get_current_user_id(),
);
echo "PUBLISHING 2.....<br>";;
try {
$new_page_id = wp_insert_post($new_page, true, false);
echo "PUBLISHING 3: id=$new_page_id.....<br>";;
} catch (Exception $ex) {
echo "EXCEPTION..... $ex<br>";;
}
sprawl
This is the output:
PUBLISHING 1.....
PUBLISHING 2.....
As I can see in the list of posts, the post is published, but execution has stopped without providing any feedback from the function or raising any exceptions.
Does anyone know how to fix it?
I can provide more information. I am running it on a local WordPress installation.