2

Adding sub menus is easy with add_submenu_page and is working fine as long if you define a $parent_slug:

add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );

if you set the $parent_slug to NULL as described here to hide it from any menu item the title of the page will get ignored ($page_title)

add_submenu_page( NULL, $page_title, $menu_title, $capability, $menu_slug, $function );

I've tested it with all versions from 3.3 up to the latest 4.0

5
  • ... Drumroll... And your question is?.... :-) Sep 10, 2014 at 11:54
  • Sorry, I've updated the headline
    – Xaver
    Sep 10, 2014 at 12:59
  • Your question should be in the body, not in the title :-) Sep 10, 2014 at 13:18
  • 1
    that is still not a question with a meaningful answer. the answer is "because whoever wrote the code thought it should be done that way" Sep 10, 2014 at 14:04
  • I think this a legit question, shouldn't the <title> tag be set regardless of whether the page has a parent or not. Perhaps this is a bug report for WP?
    – Ben
    Feb 26, 2021 at 11:43

1 Answer 1

0

It is a valid question and an issue I have encountered as well.

I did not go through the WP core code to see why the title is missing, but I can offer a solution using the admin_title filter, for people facing a similar problem:

function fix_your_page_title( $admin_title, $title ) {
    if ( get_current_screen()->id === 'your_page_id' && $title === '' ) {
        $admin_title = 'Your page title' . $admin_title;
    }    

    return $admin_title;
}

add_filter( 'admin_title', 'fix_your_page_title', 10, 2 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.