我创建了一个新的wordpress插件,它只在帖子中显示,但为了检测它是一个帖子,我尝试使用is_single(),但它不起作用。WordPress的单一undefined
class myplugin{
//my plugin code here
}
function load_plugin($plugin_class, $priority = 10) {
if (class_exists($plugin_class)) {
add_action("init",
create_function('', "global \$$plugin_class; \$$plugin_class = new $plugin_class();"),
$priority);
}
}
if(is_single()){ // witout this, the plugin is displayed everywhere, but whit it it's not displayed at all
load_plugin(myplugin);
}
我甚至想看到的is_single
echo"<script>alert('".is_single()."');</script>";
输出我得到 “未定义”
编辑//不用其他的is_single,只是加载我的插件,我的插件适用于wordpress的每一页。
你检查了错误日志吗? “不工作”并没有给我们很多去... – naththedeveloper
错误解决;) – Rezrazi