0

I have a menu(ads) that contains 2 submenus(view and manage). I want that both menu item redirect to different pages, but my 1st submenu(view) is directing to the main menu page.Both ads menu and view submenu redirecting to same page

  • You have to show your code. Please, check sscce.org And also please try not to leave unfinished Questions behind. In the previous one, I provided a working example. I don't understand what's the problem. The main menu item was removed. Do you need 3 pages or 2? Overriding the main menu with the first submenu has this exact effect. – brasofilo Oct 18 '13 at 10:31
0

Hope you'll find this well , I'm adding the code below. This is one of the way of doing it, you can do things in other ways also.

add_action('admin_menu','create_admin_menu');
function create_admin_menu()
{
    add_menu_page   (
                        'Page Title',
                        'Top level menu Title',
                        'manage_options',
                        'your_unique_slug',
                        'your_magic_function'
                    );

    function your_magic_function()
    {
        include_once('first.php');
    }

    add_submenu_page    (
                            'your_unique_slug',
                            '',
                            '',
                            'manage_options',
                            'your_unique_slug',
                            ''
                        );

    add_submenu_page    (
                            'your_unique_slug',
                            'Submenu2',
                            'Submenu2',
                            'manage_options',
                            'your_unique_submenu_slug1',
                            'your_magic_function2'
                        );


    function your_magic_function2()
    {
        include_once('second.php');
    }

    add_submenu_page    (
                            'your_unique_slug',
                            'Page Title2',
                            'Submenu Title2',
                            'manage_options',
                            'your_unique_submenu_slug2',
                            'your_magic_function3'
                        );

    function your_magic_function3()
    {
        include_once('three.php');
    }
}

first.php

<h1>First</h1>

second.php

<h2>Second</h2>

three.php

<h3>Third</h3>

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.