在子菜单-管理面板中插入链接

时间:2018-11-30 作者:wordpress dev02

嗨,这是我的代码。

add_menu_page(\'Titlemenu\', \'Titlemenu\', \'read\', \'a-functions\', array(&$this,\'namefunctions1\'));
    add_submenu_page(\'a-functions\', \'title1submenu\', \'title1submenu\', \'read\', \'a-functions\', array(&$this,\'namefunctions1\'));
    add_submenu_page(\'a-functions\', \'title2submenu\', \'title2submenu\', \'read\', \'a-functions2\', array(&$this,\'namefunctions2\'));
我想在用户单击第一个子菜单时插入文件下载。

这是将子菜单连接到要显示的页面的经典功能。

    function namefunctions1(){
    <div class="wrap">
     <?php
      include_once(dirname( __FILE__ ) . "/file.htm");
     ?>
    </div>
谢谢你的帮助

1 个回复
SO网友:Quang Hoang

You can try this.

add_action( \'admin_menu\', \'register_my_custom_menu_page\' );
function register_my_custom_menu_page() {
    add_menu_page(
        \'My Custom Page\',
        \'My Custom Page\',
        \'manage_options\',
        \'my-top-level-slug\',
        \'\',
        \'dashicons-menu\',
        6
    );
    add_submenu_page( \'my-top-level-slug\', \'My Custom Page\', \'My Custom Page\',
    \'manage_options\', \'my-top-level-slug\', \'custom_subpage_first\');
    add_submenu_page( \'my-top-level-slug\', \'My Custom Submenu Page 1\', \'My Custom 
    Submenu Page\',\'manage_options\', \'my-secondary-slug\', \'custom_subpage_second\');
}

function custom_subpage_first() {
?>
    <div class="wrap">
       <?php include_once(dirname( __FILE__ ) . "/file.htm");?>
    </div>
<?php
}
function custom_subpage_second() {
?>
    <div class="wrap">
       /*Second subpage content */
    </div>
<?php
}

相关推荐

Order Admin sub-menu items?

我正在使用向CPT管理菜单添加项目add_submenu_page 这很好,但它们被添加到CPT选项后的子菜单底部。我希望能够将它们放在最上面,但我想这个问题也可以应用于订购所有基于管理员的子菜单项。我所尝试的(不起作用,我尝试了几种变体),function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( \'edi