Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

1 Answer

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>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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