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.

Comments

Add comment
  • Comment list is empty

Contact Us

020-2206-9892

QQ咨询:1025174874

E-mail: info@361sale.com

Working hours: Monday to Friday, 9:30-18:30, holidays off

Customer Service
In order to facilitate global user registration and login, we have canceled the telephone login function. If you encounter login problems, please contact our customer service for assistance in binding your email address.