SOHO建站

标签: WP后台自定义

共找到相关结果约2个

为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!';
}

拥有编辑权限的用户可见

wordpress自定义后台右下角文字

把wordpress后台修改的更个性化,可以通过下面的方式。

add_filter("admin_footer_text", function () {
    return "by wodepress.com";
});

将以下代驾添加到functions.php文件中即可现实。