Wordpress add_submenu_page函数无效

时间:2013-02-06 09:42:19

标签: php wordpress menu

我需要为wordpress管理员创建一个新菜单和一个子菜单项。菜单工作正常,但子菜单项(主菜单项的重复子菜单正在自动创建..我不希望这样)。两个子菜单项的href属性都为空。我不明白菜单slu is是什么。请帮忙..

    // create custom plugin settings menu  
       add_action('admin_menu', 'retail_create_menu');

       function retail_create_menu() { //create new top-level menu
          add_menu_page('Retailers', 'Retailers', 'administrator', __FILE__, 'generate_retailer_list', 'http://localhost/apsm/wp-content/themes/wp-mediamag/functions/retail.ico'); 
          add_submenu_page( __FILE__, 'Add Retailers', 'Add Retailers', 'administrator', 'add_ratilers.php', 'retailer_submenu_callback');
       }

该文件位于我主题的文件夹中......


This is what the menu looks like

1 个答案:

答案 0 :(得分:1)

隐藏重复菜单的一个简单方法:

add_submenu_page(
    '__FILE__',        // parent slug, same as main menu slug
    '',        // empty page title
    '',        // empty menu title
    'administrator',        // same capability as parent
    '__FILE__',        // same menu slug as parent slug
    'generate_retailer_list',        // same function as parent
)