如何在自定义PHP脚本中调用WordPress函数 [英] How to call WordPress functions in a custom PHP script
问题描述
我有一个PHP脚本,希望用于在WPMU中创建新博客.我在调用WordPress功能时遇到麻烦,例如 wpmu_create_user 和
I have a PHP script I want to use for creating a new blog in WPMU. I am having trouble calling WordPress functions like wpmu_create_user and wpmu_create_blog.
我的希望是从命令行中以 cron 作业的形式运行该脚本,并从外部数据库获取新博客创建请求,使用WordPress函数创建新博客,并使用新博客信息更新数据库.
My hope is to get this script running as a cron job from the command line and pick up new blog creation requests from an external db, create a new blog using the WordPress functions and update the database with the new blog information.
推荐答案
将wp-load.php文件(在wordpress安装的根目录中)包括在php脚本文件中,
include wp-load.php file (in the root of your wordpress installation) in your php script file like so,
require_once("/path/to/wordpress/wp-load.php");
您将必须提供wp-load文件的绝对路径, 现在,您可以在php脚本中使用wordpress的所有功能
you will have to provide the abspath of the wp-load file, now you can use all the functions of wordpress in your php script
这篇关于如何在自定义PHP脚本中调用WordPress函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!