文章描述:
WordPress后台仪表盘有六个模块,分别是站点健康状态、概览、活动、快速草稿、WordPress活动及新闻、Welcome,每个模块都有不同的作用,那我们如何在仪表盘新增自定义模块呢?
新增模块
在主题模板functions.php里面自定义模块、模块内容、加载模块:
自定义模块
function guihet_add_dashboard_widgets() {
wp_add_dashboard_widget(\'custom_help_widget\', \'自定义模块\', \'custom_dashboard_guihet\');
}
加载模块
add_action(\'wp_dashboard_setup\', \'guihet_add_dashboard_widgets\' );
模块内容
function custom_dashboard_guihet() {
echo \"<ul>\";
echo \"<li>站点首页:<a href=\'\".get_option(\'home\').\"\' target=\'_blank\'>\".get_option(\'home\').\"</a></li>\";
echo \"<li>网站地图:<a href=\'\".get_option(\'home\').\"/sitemap.xml\' target=\'_blank\'>\".get_option(\'home\').\"/sitemap.xml</a></li>\";
echo \"</ul>\";
}
多个模块
在自定义模块里面添加
wp_add_dashboard_widget(\'custom_tool_widget\', \'自定义工具模块\', \'custom_dashboard_guihet_tool\');
在外面添加模块内容
function custom_dashboard_guihet_tool(){
}
THE END
请登录后查看评论内容