Php – Adding the custom page with add_menu_page function on WordPress

PHPWordpress

I am using the add_menu_page function on WordPress, this is the code;

function my_admin_menu() {
    add_menu_page( 'My Top Level Menu Example', 'Top Level Menu', 'manage_options', 'example.php', 'myplguin_admin_page', 'dashicons-tickets', 6  );
}

then the example.php file:

function display_text() {

echo'Welcome to my page'

}

I get the menu in the dashboard but the issue is having content on the page, I can click the option top level page from the dashboard but once I do that I just get an empty page where it should say 'Welcome To My page'

Any Ideas on how to get my content to show?

Best Answer

Use this code it will work for you. you was used wrong function name thats why it is showing blank page

 function my_admin_menu() {
        add_menu_page( 'My Top Level Menu Example', 'Top Level Menu', 'manage_options', 'example.php', 'myplguin_admin_page', 'dashicons-tickets', 6  );
    }

    function myplguin_admin_page(){
    echo 'Welcome to admin page';
    }
Related Topic