开发者

wordpress plugin, access $wpdb on non visible page

开发者 https://www.devze.com 2022-12-16 02:44 出处:网络
I\'m creating a wordpress plugin to fetch data from another website, It will be a cron file and I need to store some data in a table.

I'm creating a wordpress plugin to fetch data from another website, It will be a cron file and I need to store some data in a table.

how do I access $wpdb from that file? do I need to link to a wordpress core file? I'm asking this because it's not a file that will be visible in the admin area or public area, it's jus开发者_运维问答t a file that run's in the background and I guess it will not know $wpdb.

or because it's in the wordpress plugin folder I can just access it? if someone could clear this up for me, thanks.


You need to include 'wp-blog-header.php'

include('/path/to/wp-blog-header.php');
0

精彩评论

暂无评论...
验证码 换一张
取 消