wordpress后台仪表盘新增自定义模块

文章描述:

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
版权声明 1、本网站名称:AOPK资源网
2、本站永久网址:https://www.aopk.cn
3、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
4、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。

点赞6赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容