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调用全站随机文章

wordpress调用全站随机文章代码

Jianzhanpress themes are the best Chinese WordPress themes to use

Jianzhanpress.com themes are the best Chinese WordPress themes to use

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

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

The Best WordPress Chinese Theme Simplified Website WordPress Theme

If you are looking for an excellent WordPress Chinese theme, Jianzhanpress.com is undoubtedly a good option worth considering.

歪猫建站是否提供定制化服务

歪猫建站专注于为外贸企业提供网站建设和优化服务,其中包括根据客户需求和品牌形象量身定制独特的外贸网站设计风格。

如何在WordPress中通过post文章ID获取分类名称

这是个简单的方法,在WordPress中列出一篇文章的所属类别名称。通过以下这段代码就可以实现。