如何在 WordPress 管理菜单中创建新按钮

Dmi*_*nov 1 wordpress

请告诉我如何在此处创建新按钮(位于仪表板左侧导航的底部):http://prntscr.com/6rlbda

该按钮只需要传输一个GET参数。

谢谢。

Wil*_*ell 5

您无法将“按钮”添加到菜单栏,只能添加标准链接(尽管您可以选择图标。)

此外,您的问题并未指定您实际希望按钮(或其链接到的页面)执行的操作但标准方法是:

add_action( 'admin_menu', 'register_my_menu_item' );

function register_my_menu_item() {
    # the add_action ensures this is only run when admin pages are displayed
    add_menu_page( 'Example page', 'Example menu', 'manage_options', 'query-string-parameter', 'my_menu_item');
}

function my_menu_item() {
    # your new admin page contents (or behaviour go here)
    echo 'Hello World!';
}
Run Code Online (Sandbox Code Playgroud)

(理想情况下,这应该放在插件中,但也可以放在您的主题中functions.php

文档: https: //codex.wordpress.org/Function_Reference/add_menu_page