admin管理员组文章数量:1406063
I have a genuine mystery. With this code (in an ajax call):
file_put_contents(ABSPATH.'wp-content/debug.log', 'Inserting new note' . PHP_EOL, FILE_APPEND);
$post_id = wp_insert_post( array(
'post_title' => sanitize_text_field( $title ),
'post_status' => 'publish',
'post_type' => 'coursenote',
'post_content' => $_POST['data']['body']
), true );
file_put_contents(ABSPATH.'wp-content/debug.log', 'WTF' . PHP_EOL, FILE_APPEND);
I am seeing the new post in the database, but the wp_insert_post
function is somehow not returning (evidenced by fact that second file_put_contents is not doing anything.
I don't know if it has to do with other ajax calls or something. Just really odd that everything is fine til wp_insert_post's return.
Can anyone think of a reason why this could happen?
thanks, Brian
Edit:
So I found the problem. Some really awful programmer had an exit;
call in a save_post
hook in a plugin. That resulted in the script not returning to the calling script (wp_insert_post
).
That awful programmer is the author of this question :-) And the offensive exit
is now a return
本文标签: postsAny idea why wpinsertpost is succeeding but not returning
版权声明:本文标题:posts - Any idea why wp_insert_post is succeeding but not returning? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744958670a2634515.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论