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主题,简站主题的基础框架是固定的,呈现出来的东西,都在后台有对应修改的地方,使用起来非常方便。

wordpress子页面获取父页面的标题和链接

wordpress子页面获取父页面的标题和链接

打造专业WP外贸建站平台功能全面解析

  在全球化的商业环境中,拥有一个专业且高效的外贸网站对于企业的成功至关重要。WordPress作为一款强大而… Continue reading 打造专业WP外贸建站平台功能全面解析

WordPress有没有必要选择付费主题

能用付费的就别用免费的

WordPress创始人Matt的创业故事

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

获取wordpress主题目录路径的函数

调用wordpress主题目录路径的方法