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?
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?
Share Improve this question asked Jan 23, 2019 at 10:30 Diana RiderDiana Rider 4911 bronze badges 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. – Jacob Peattie 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
Reset to default 1To those who are experiencing the same issue, there are few steps to take to determine the culprit.
- Create posts manually in the WP Dashboard area (set it to future)
- .. and manually publish (look for the error in the log).
- 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).
- Check for any plugin which filters the post publish.
Hope this helps
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 );