傻大憨

为wordpress后台添加一个自定义页面

非插件线代码方式实现为wordpress后台添加一个自定义页面

参数如下:

$page_title (string) – The text to be displayed in the title tags of the page when the menu is selected.
$menu_title (string) – The text to be used for the menu.
$capability (string) – The capability required for this menu to be displayed to the user.
$menu_slug (string) – The unique slug name to refer to this menu.
$callback (callable, optional) – The function to be called to output the content for this page. Default: ”
$position (int, optional) – The position in the menu order this item should appear. Default: null

将下面代码添加到functions.php中即可实现

function my_plugin_menu() {
    add_dashboard_page('My Custom Dashboard', 'Custom Dashboard', 'read', 'wodepress-custom-dashboard', 'wodepress_custom_dashboard_output');
}
add_action('admin_menu', 'my_plugin_menu');

function wodepress_custom_dashboard_output() {
    echo 'Welcome to My Custom Dashboard!';
}

所有登陆后台的用户可见

function my_plugin_menu() {
    add_dashboard_page('My Custom Dashboard', 'Custom Dashboard', 'edit_posts', 'wodepress-custom-dashboard', 'wodepress_custom_dashboard_output');
}
add_action('admin_menu', 'my_plugin_menu');

function wodepress_custom_dashboard_output() {
    echo 'Welcome to My Custom Dashboard!';
}

拥有编辑权限的用户可见

Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

wordpress给指定ID的分类目录分页添加不同数量文章

不同分类显示不同的文章数量

WordPress外贸整站源码的实际应用技巧

     在WordPress外贸建站的过程中,源码的开发与运用是深入了解和定制网站的关键步骤。本文将分享一些… Continue reading WordPress外贸整站源码的实际应用技巧

预算1000元左右 wordpress模板建站是明智选择

千元预算建站:为什么WordPress模板是你的唯一明智选择 对于中小企业主和创业者来说,”网站建… Continue reading 预算1000元左右 wordpress模板建站是明智选择

同一个数据库安装两个或多个wordpress网站方法

同一个数据库内怎么安装多个wordpress网站。

实现wordpress一篇文章只允许同一IP评论一次

让一个IP只能评论一次

中英文wordpress主题资源网站推荐

推荐一个英文wordpress建站资源网站和一个中文wordpress建站模板网站。