王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

给wordpress仪表盘增加自定义信息模块

我们在做wordpress主题开发的时刻,为了越发的让使用者熟习本身做的wordpress主题,都会在主题背景做细致的形貌,有的时刻会想到在仪表盘上也加些教程链接和申明越发好,那末本日就教人人怎样wordpress仪表盘增加自定义信息模块,下面就直接说教程了,翻开你们wordpress主题的functions.php文件,将一下代码到场:

  1. function custom_dashboard_help() {

  2. echo '这里填使用申明的内容,可填写HTML代码';

  3. }

  4. function example_add_dashboard_widgets() {

  5.     wp_add_dashboard_widget('custom_help_widget', '这里替换成面板标题', 'custom_dashboard_help');

  6. }

  7. add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

修正以上代码为本身的内容,再去仪表盘看看,是不是多出了自定义的信息模块涌现了!

别的同时教程也给出,怎样去掉wordpress仪表盘中无用的其他模块吧,一样照样在wordpress主题文件里的functions.php文件中到场以下代码:

  1. //删除仪表盘模块  

  2. function example_remove_dashboard_widgets() {  

  3.     // Globalize the metaboxes array, this holds all the widgets for wp-admin  

  4.     global $wp_meta_boxes;  

  5.     // 以下这一行代码将删除 "疾速宣布" 模块  

  6.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);  

  7.     // 以下这一行代码将删除 "引入链接" 模块  

  8.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);  

  9.     // 以下这一行代码将删除 "插件" 模块  

  10.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);  

  11.     // 以下这一行代码将删除 "近期批评" 模块  

  12.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);  

  13.     // 以下这一行代码将删除 "近期草稿" 模块  

  14.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);  

  15.     // 以下这一行代码将删除 "WordPress 开发日记" 模块  

  16.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);  

  17.     // 以下这一行代码将删除 "别的 WordPress 消息" 模块  

  18.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);  

  19.     // 以下这一行代码将删除 "概略" 模块  

  20.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);  

  21. }  

  22. add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );  

  23. // 以下这一行代码将删除 "welcome" 模块  

  24. remove_action('welcome_panel', 'wp_welcome_panel');  

依据以上解释去去掉本身所需要去掉的模块吧!

相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。