What is the use of $page_title and how to use it?

Ok my bad found the answer on the codex page but at the very bottom so I’m adding this here as well so if anyone like my didn’t catch it on WordPress’s codex, they can find it here 🙂

Just use get_admin_page_title();

See the example 1 below:

function register_my_custom_submenu_page() {
    add_submenu_page( 
        'tools.php', 
        'My Custom Submenu Page', 
        'My Custom Submenu Page', 
        'manage_options', 
        'my-custom-submenu-page', 
        'my_custom_submenu_page_callback' 
    );
}

function my_custom_submenu_page_callback() {
    echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
        echo get_admin_page_title();
    echo '</div>';
}

And here is the example 2 below:

function register_my_custom_submenu_page() {
    add_submenu_page( 
        'tools.php', 
        'My Custom Submenu Page', 
        'My Custom Submenu Page', 
        'manage_options', 
        'my-custom-submenu-page', 
        'my_custom_submenu_page_callback' 
    );
}

function my_custom_submenu_page_callback() {
    global $title;
    echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
        echo $title;
    echo '</div>';
}

Leave a Comment