0

I am creating Wordpress Dashboard Menu:

add_action('admin_menu', 'personalised_menu');

function personalised_menu() {

    add_menu_page(
          'Page Title'
        , 'Blog'
        , 'edit_posts'
        , 'menu_slug'
        , 'call_user_func_array'
        , 'dashicons-welcome-write-blog'
    );

    add_submenu_page(
          'menu_slug'
        , 'Add New Page'
        , 'Add New'
        , 'edit_posts'
        , 'add_new_page'
        , 'call_user_func_array'
    );

}
2

Replace 'call_user_func_array' with name of the function to be called to output the page content.

add_action('admin_menu', 'personalised_menu');
function personalised_menu()
{
   add_menu_page( 'Page Title', 'Blog', 'edit_posts', 'menu_slug',
       'display_main_page', 'dashicons-welcome-write-blog' );
   add_submenu_page( 'menu_slug', 'Add New Page', 'Add New', 'edit_posts','add_new_page', 
        'display_secondary_page' );
}

function display_main_page() {
    echo 'Content of "Page Title"';
}

function display_secondary_page() {
    echo 'Content of subpage';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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