【发布时间】:2019-02-20 17:57:19
【问题描述】:
我正在使用wordpress 4.9.8 和PHP 7.1.8 我想从我的类中加载一个函数。
插件类位于:
C:\Users\admin\Desktop\wordpress\wp-content\plugins\content-creator\includes\SinglePostContent.php
我的function.php 文件位于以下文件夹中:
C:\Users\admin\Desktop\wordpress\wp-content\themes\rehub-blankchild\functions.php
我要加载的函数如下所示:
class SinglePostContent
{
public function __construct()
{
//...
}
public function main($postID)
{
//...
}
我尝试使用
add_action('wp_ajax_updateContent', 'updateContent');
function updateContent()
{
$post_id = intval($_POST['post_id']);
try {
SinglePostContent::main($post_id); // HERE I get the error!
} catch (Exception $e) {
echo $e;
}
wp_die();
}
关于如何在我的 function.php 中加载类 SinglePostContent 的任何建议
【问题讨论】:
-
SinglePostContent是否存在于您未引用的特定命名空间中?