how change my menu on submenu

时间:2017-05-23 作者:Wojciech Szydłowski

我的菜单中有一个选项,我不会在子菜单上更改它,但我只有失败。。。

// Call Terms_and_conditions_menu is function which load plugin menu
add_action( \'admin_menu\', \'Terms_and_conditions_menu\' );

// Add to WordPress admin menu
if( !function_exists("Terms_and_conditions_menu") )
{
function Terms_and_conditions_menu(){

  $page_title = \'WordPress Extra Post Info\';
  $menu_title = \'Terms And Conditions\';
  $capability = \'manage_options\';
  $menu_slug  = \'terms-post-info\';
  $function   = \'terms_post_info_page\';
  $icon_url   = \'dashicons-media-code\';
  $position   = 4;

  add_menu_page( $page_title,
                 $menu_title,
                 $capability,
                 $menu_slug,
                 $function,
                 $icon_url,
                 $position );
标记我要添加的菜单:wpjb config

1 个回复
SO网友:Sam

您可以添加如下子菜单。

  // Call Terms_and_conditions_menu is function which load plugin menu
    add_action( \'admin_menu\', \'Terms_and_conditions_menu\' );

    // Add to WordPress admin menu
    if( !function_exists("Terms_and_conditions_menu") )
    {
    function Terms_and_conditions_menu(){

      $page_title = \'WordPress Extra Post Info\';
      $menu_title = \'Terms And Conditions\';
      $capability = \'manage_options\';
      $menu_slug  = \'terms-post-info\';
      $function   = \'terms_post_info_page\';
      $icon_url   = \'dashicons-media-code\';
      $position   = 4;

      add_menu_page( $page_title,
                     $menu_title,
                     $capability,
                     $menu_slug,
                     $function,
                     $icon_url,
                     $position );

    add_submenu_page( $menu_slug,\'sub page\', \'menu title\',$capability, \'my-secondary-slug\');

    function my-secondary-slug(){

      echo \'Page text\';
    }

结束