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文章摘要显示的字数长度,数值为字符号,汉字占两个字符。

靠谱是对一个建网站公司的最好评价

靠谱是对一个建网站公司的最好评价,它不仅代表着公司的专业能力和服务质量,更体现了客户对其的信任和认可。

wordpress禁用xmlrpc

将以下代码插入到functions.php文件中即可

海外华人爱用简站wordpress主题搭建网站的10大原因

简站WordPress主题因其语言支持、本地化服务、简洁易用、SEO优化、响应式设计、定制性、成本效益、社区和支持、安全性以及兼容性等特点,受到了许多海外华人网站搭建者的欢迎。

询盘鸭跨境电商独立站建站平台

询盘鸭是专业的WordPress+WooCommerce跨境电商独立站解决方案服务商。