从插件中调用:
$my_post = array(
'post_title' => 'Test',
'post_content' => 'Testing wp_insert_post()'
);
wp_insert_post($my_post);
导致一个很长的错误消息:
致命错误:Uncaught error: Call to undefined functionis_user_logged_in() in C:'Program Files(x86) ' ampp ' www '开发' wordpres…
谁能解释一下为什么和如何使这个工作?
如果您尝试在WP结构之外使用此代码,则需要将require_once("path/to/wordpress/wp-load.php");
包含在页面顶部。
但是如果没有,那么你需要检查你的插件。你可以在这里搭车