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不同tag标签 添加不同模板

怎么让wordpress网站的不同tag标签,显示不同的模板,用下面这段代码就够了。

给wordpress添加自定义字段的分类筛选功能

这段代码创建了一个简单的筛选表单,用户可以在其中输入自定义字段的键和值,然后点击“筛选”按钮来提交表单。

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

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

WordPress外贸建站课程的深度专业之道

  随着国际贸易的不断发展,拥有一流的WordPress外贸建站技能变得至关重要。在这篇文章中,我们将探讨高级… Continue reading WordPress外贸建站课程的深度专业之道

这次wordpress被黑出屎了

今年收到这么一个问题: 如果一个公司的网站是wordpress搭建的说明该公司规模很小吗? wordpress… Continue reading 这次wordpress被黑出屎了

wordpress含二级菜单自定义代码

这只是一个基本的示例代码,您可以根据需要进行修改和定制。确保在使用自定义代码时备份您的主题文件,以防止意外情况发生。