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?

  • 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. – Jacob Peattie Jan 23 at 10:35
  • 'post_status =>' publish' should be 'post_status' => 'publish' – shanebp Jan 25 at 15:27

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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