我正在为wordpress主题创建一个插件,它将模板加载到自己的目录中,而不是在主题中放置模板,使我独立于主题中包含模板,因为我创建了用于在条件下加载不同模板的短代码 . 以下是代码:
add_shortcode('template','add_template'); function add_template($ atts){extract(shortcode_atts(array('template'=>''),$ atts)); switch($ template){case'template1':
包括'templates / template1.php';
打破;
案例'template2':
包括'templates / template2.php';
打破;
默认:
包括'templates / template1.php';
打破;
}
}
我的问题是在某些主题我的插件开始在管理面板中显示页面有什么我做错了吗?请帮忙....
1 回答
找到一个解决方案,我们只需要在包含模板之前添加一个用户不是管理员的检查 .