0

I have a script that automatically makes posts and uses insert_post() to do so. Running the script works but after a few loops (running insert_post()) the script just ends without any warnings or errors after trying to run insert_post(). The last post is made and shows up in the database but the function insert_post doesn’t even return an id. The script just ends. I have no idea why.

I checked and all the inputs are the fine but it just stops after a few times. It is not a timeout issue either because I was running with no timeout.

It wasn’t happening yesterday but now it is. I didn’t change the script.

for(...) { $new_post = array(
      'post_content' => $content,
      'post_title' => $title,
      'post_status' => 'publish',
);
$post_id = wp_insert_post($new_post); }

wp_insert_post never returns and the script ends

4
  • You are most likely running out of memory. How many times do you run the for loop? How heavy are the content of your posts? and how much ram is available for your installation?
    – Johansson
    Commented Sep 8, 2018 at 20:50
  • it is now literally dying after the second post and the posts are not heavy on content. Content is mostly added after the post is created and it is dying on the actual insert. Commented Sep 8, 2018 at 21:10
  • I have plenty of ram available php memory limit is set to 64M atm. Commented Sep 8, 2018 at 21:18
  • so I now think it is an external plugin issue because I went into the actual insert_post code and debugged. It is dying on the last 2 do actions which are probably connected to some plugins. Not sure exactly how to fix it correctly yet but that's where the issue is. Commented Sep 8, 2018 at 21:31

1 Answer 1

0

turned out to be a problem with an external plugin. Was failing(dying) on the last 2 do_actions() in the function wp_insert_post(). Not sure how to fix that problem yet but this question is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.