Support » How-To and Troubleshooting » [Resolved] Drop downs not working

[Resolved] Drop downs not working

  • Any idea why this code won’t work to create drop downs on the Services tab on this site — I’ve used this many times before:


    I’ve set the Parent page to Services for the 3 sub pages.

    Used this code — I double checked the page ID and it’s correct.

    <div class=”topnav”>

    • <?php wp_list_pages(‘include=4&title_li=&depth=1’);?>
    • <?php wp_list_pages(‘include=16&title_li=&depth=1’);?>
    • <?php wp_list_pages(‘include=29&title_li=&depth=1’);?>
    • <?php wp_list_pages(‘include=13&title_li=&depth=3’);?>
    • <?php wp_list_pages(‘include=6&title_li=&depth=1’);?>
    • <?php wp_list_pages(‘include=9&title_li=&depth=1’);?>

    <div class=”clr”></div>

    Thanks much in advance!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Each of those calls to wp_list_pages() will only show one page as you only have one page ID in the include parameter.

    I thought the depth=3 will pull in the sub pages under the Services page? I’ve used this code before….??

    Oh, so I have to include the ID of the other pages….right!

    Yes thats right. I am confused as to why you all the instances of wp_list_pages. Could you not just include it once?

    Yes, so would it be:

    <?php wp_list_pages(‘include=4,16,29,13,37,34,406,9,&title_li=&depth=4’);?>

    where the sub pages come right after the Parent page (13)?

    Woops, depth=4

    <?php wp_list_pages(‘include=4,16,29,13,37,34,406,9,&title_li=&depth=4’);?>

    Or would it be:

    <?php wp_list_pages(‘include=4,16,29,9,&title_li=&depth=1’);?>

    <?php wp_list_pages(‘include=13,37,34,406&title_li=&depth=4’);?>

    Where first is navs with no drops and second is nav with drop downs?

    As far as I am aware if you use the include parameter the depth is irrelevant as WordPress will only include pages you have added to the include parameter. So in the example above it will only includes pages with IDs 4,16,29,13,37,34,406 and 9.

    I would think about using the new wp_nav_menu instead then you have drag and drop control over which pages etc are in your menu.

    So they way it determines whether it’s a drop down is by tagging the sub page with a parent page?

    Where’s the wp_nav_menu? I’m using a theme that’s not the one installed in 3.2.1.

    To be a drop down there would need to be a depth of at least 2 so that it can nest the links in another unordered list. However if you use ‘include’ then the depth will not work unless one of the page IDs you have included is a child page.

    Eh gads…..so what’s the right way to do it?

    I tried this and it won’t stay in the order I’d like the pages to be.I think that’s why I used all the lis. Is there a simpler way?

    <?php wp_list_pages(‘include=4,16,29,13,37,34,406,9,&title_li’);?>

    37,34,406 are all child pages of 13. Order not working though.

    The best way is to implement the wp_nav_menu into your theme and then you can have full control.

    Where do I implement that?

    In the header.php?

    Would it be :

    <div class=”topnav”>
    <ul id=”nav_menu”>
    <?php wp_list_pages(‘include=4,16,29,13,37,34,406,9,&title_li’);?>
    It won’t display the closing ul here.

    And then style the nav_menu?

    A good starting point for wp_nav_menu is here:


    Okay, thanks. Let me take a look.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Resolved] Drop downs not working’ is closed to new replies.