最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can't publish post using ajax

programmeradmin1浏览0评论

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
Add a comment  | 

2 Answers 2

Reset to default 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

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论