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是一个关注跨境电商、创业话题的网站。

The best foreign trade website building company in Shenzhen

Waimaoyes is a company specializing in foreign trade website construction, mainly providing WordPress multilingual foreign trade small language website construction services.

北京的外贸网站建设与海外推广

傻大憨是一家位于首都北京的外贸网站建设与海外推广公司,专注于为北京及周边三河四省的外贸企业提供高质量的Google SEO服务。

wordpress搜索自字义字段内容

有些网站需要根据自定义段字的内容来做为搜索项,比如,房产中介公司wordpress网站,需要搜索同一区域内容的楼盘,然后展示出内容。

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

  WordPress作为一款强大的建站平台,为外贸企业提供了丰富的功能和灵活的定制选项。在这篇文章中,我们将… Continue reading WordPress外贸网站建设的成功要素与技术点

一站式解决方案为你打造专业wordpress网站

  在当今数字化时代,对于外贸企业而言,拥有一个专业、易于管理的网站是取得成功的关键之一。然而,对于网络小白来… Continue reading 一站式解决方案为你打造专业wordpress网站

我能否完全按照我的需求来设计wordpress网站

简站wordpress主题是我用过最简洁最好用的wordpress主题,简站主题的基础框架是固定的,呈现出来的东西,都在后台有对应修改的地方,使用起来非常方便。