Missing includes in Wordpress plugin (wp_insert_post function)
I created a code开发者_运维百科 which generates content and I want to populate Wordpress's database with it. I am using wp_insert_post
and add_post_meta
functions but every time I load which triggers the script I get this error:
Fatal error: Call to undefined function add_action() in \www\scriptmafia\wp-includes\post.php on line 153
To my mind it due to some missing includes. I have included post.php which it mentioned as required include for wp_insert_post
function.
I know this is pretty common among newbies in WordPress. However, any solution I have tried have not worked for me.
require_once( ABSPATH . '/wp-load.php'); should solve it :)
精彩评论