SOHO创业

为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 SOHO

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

WordPress外贸建站平台的核心特征大揭秘

  在选择WordPress外贸建站平台时,深入分析所需功能是确保您的网站成功的重要一步。本文将揭示WordP… Continue reading WordPress外贸建站平台的核心特征大揭秘

WordPress外贸建站平台在行业的领导地位

  在数字时代,建立一个强大而具有影响力的国际外贸网站对于企业来说至关重要。WordPress外贸建站平台凭借… Continue reading WordPress外贸建站平台在行业的领导地位

WordPress外贸建站教程实用技巧分享

  WordPress外贸建站平台以其简便、灵活的特点成为许多企业打造专业网站的首选工具。在这篇文章中,我们将… Continue reading WordPress外贸建站教程实用技巧分享

为不同文章形式选择不同的WordPress文章模板

在写文章的时候选择不同的文章形式,然后打开文章的时候会调用不同文章形式的模板。比如,文章形式为video ,就调用single-video.php模板,其它文章形式类似,可以添加多个文章样式。

自定义WordPress顶部的菜单的方法

要自定义WordPress顶部的菜单,你需要使用WordPress的菜单系统。首先,你需要创建自定义菜单,然后将其设置为顶部导航菜单。

WordPress外贸网站建设的成功因素与技术点

  在竞争激烈的网络环境中,打造一家成功的外贸网站需要精心规划和技术实力。本文将揭晓一些成功建站的秘籍,重点聚… Continue reading WordPress外贸网站建设的成功因素与技术点