1

I have an issue, i create three input in frontend(title, body, and name)

I process the value using wp-ajax, and in my ajax function I use wp_insert_post to create a new post.

if I put 'post_status =>' publish' in my wp_insert_post, I get error 500 in ajax-admin, but if I remove it my code is fine.

I want create a post with publish status. I also already put wp_publish_post after wp_insert_post in same ajax-function. but also getting 500 error.

Is there any solution for this issue?

3
  • 1
    Please include the actual code in the question, otherwise it’s impossible to know what the issue is. Based on your description though my guess is that you’re missing a comma after the line you’re adding. Commented Jan 23, 2019 at 10:35
  • 'post_status =>' publish' should be 'post_status' => 'publish'
    – shanebp
    Commented Jan 25, 2019 at 15:27
  • I also experienced the same, not sure how it came up like this, it just suddenly happening.
    – Ryan S
    Commented Aug 23, 2019 at 13:23

2 Answers 2

1

To those who are experiencing the same issue, there are few steps to take to determine the culprit.

  1. Create posts manually in the WP Dashboard area (set it to future)
  2. .. and manually publish (look for the error in the log).
  3. step 1 and trash the post, in the Trash, try reverting that post (this generally create a log, and a log is all we need in this case).
  4. Check for any plugin which filters the post publish.

Hope this helps

0

To troubleshoot WordPress errors, you require to enable WordPress Debug, which can be done using wp-config.php. You need to copy and paste the code in wp-config.php file shown below. define( 'WP_DEBUG', true );

1
  • In an ajax request this won't give any help.
    – Ryan S
    Commented Aug 23, 2019 at 13:23

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.