I have a website built with WordPress and I've been using the code snippets plugin in order to automate some backend stuff. I've been trying to create posts automatically but every time I run the snippet the post is created, however my website crashes, displaying the "A critical error has occured on your website" screen and and the rest of the snippet is not executed. This is the content of the snippet in question:
$new_page_args = array( 'post_type' => 'product', //the custom type of the post I'm trying to create 'post_title' => 'My new product', 'post_status' => 'publish', 'post_author' => 1 ); $post_id = wp_insert_post($new_page_args, true); //this should create the post and return its id, //or a wp_error if something goes wrong
The problem is that since the snippet crashes immediately after executing wp_insert_post() I have no way of printing the error and figuring out what's wrong. Any input on how to fix this or even how to go about debugging it would be very welcome.