How do you add a WordPress admin page without addi

2019-01-30 13:53发布

I'm building a WordPress plugin and I'd like to have an edit-item page that can't be reached via the submenu (because then the item wouldn't be specified).

This resource (http://codex.wordpress.org/Adding_Administration_Menus) shows how to associate an admin page with a function, but not how to do so without adding it as a menu item.

Can this be done?

Thanks!

标签: wordpress
12条回答
\"骚年 ilove
2楼-- · 2019-01-30 14:21

Best solution here http://wordpress.org/support/topic/add-backend-page-without-menu-item

use add_submenu_page with parent slug = null

查看更多
淡お忘
3楼-- · 2019-01-30 14:21

use this code for creating new page without adding in menu

add_action( 'admin_menu', 'register_newpage' );

function register_newpage(){
    add_menu_page($appname, $appname, 'administrator','custompage', 'custom');
    remove_menu_page('custom');
}

function custom()
{
echo "hai";
}
查看更多
Luminary・发光体
4楼-- · 2019-01-30 14:23

Create sub menu page and parent slug leave it empty like this:

// Create page were you can add new users.
    public function add_create_user_menu() {
        add_submenu_page(
            '',
            'Create User',
            'Create User',
            'manage_options',
            'create-user',
            array( $this, 'add_create_user_page' )
        );
    }

You can access it like this:

<a href="/wp-admin/admin.php?page=create-user">Add New</a>
查看更多
老娘就宠你
5楼-- · 2019-01-30 14:25

I find you can do it by reusing the insert id, like so:

add_menu_page( 'User AS Packages', 'User AS', 'manage_options', 'myplugin/editaspackages.php', 'UserASPackages', '', 8);
add_menu_page( 'User ARP Packages', 'User ARP', 'manage_options', 'myplugin/editarppackages.php', 'UserARPPackages', '', 8);
add_menu_page( 'AS Packages', 'AS Packages', 'manage_options', 'myplugin/ars-s2.php', 'ARPPackages', '', 8);

The last 3 using position 8 and the last one overrides the two before so the two before do not appear.

查看更多
Summer. ? 凉城
6楼-- · 2019-01-30 14:27

I've tried all of the suggestions here but with various issues associated with each.

The WordPress codex for add_submenu_page now gives the correct answer, which is to use options.php as your parent slug. I tried the trick of using a made up name but that gives permissions errors, equally use of null at various locations either causes the menu text to simply be missing (but still clickable) or for the browser title to go missing.

Using options.php worked and I've not seen any issues as a result of its use.

查看更多
聊天终结者
7楼-- · 2019-01-30 14:28

add_submenu_page with parent slug = null

OR

add_submenu_page with menu title = null

查看更多
登录 后发表回答