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创始人Matt的创业故事

最近看了一个采访 Matt 的视频,他是 WordPress 的创始人,Automattic 公司的 CEO 。他在视频里讲了自己当初做 WordPress 的起因,还有创建 Automattic 公司的故事,描述了跟投资人的关系。

WordPress外贸网站建设的关键要素与技术要点

  在全球数字化的时代,成功建站是拓展国际业务的关键一环。本文将揭示WordPress外贸网站建设的关键要素与… Continue reading WordPress外贸网站建设的关键要素与技术要点

wordpress怎么调用页面别名

在制作wordpress主题时常常会用到调用页面的别名,下面这段代码可以完美解决,wordpress页面别名调用的问题。

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

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

GGD独立站与DTC独立站的区别

GGD独立站(可能指“工厂直销独立站”或“Global Goods Direct”)与DTC独立站(Direct-to-Consumer,直接面向消费者)在商业模式、目标受众和运营策略上存在显著差异。

如何在wordpress顶部header.php中引用css/bootstrap.css文件

在 WordPress 的 header.php 文件中引用 CSS 文件(如 bootstrap.css)是实现主题样式化的一种常见方式。以下是具体的步骤和代码示例