WordPress.org

Forums

[resolved] Drop downs not working (19 posts)

  1. Sculley
    Member
    Posted 4 years ago #

    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:

    thestudio88.com

    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>
    </div>

    Thanks much in advance!

  2. equalmark
    Member
    Posted 4 years ago #

    Each of those calls to wp_list_pages() will only show one page as you only have one page ID in the include parameter.

  3. Sculley
    Member
    Posted 4 years ago #

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

  4. Sculley
    Member
    Posted 4 years ago #

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

  5. equalmark
    Member
    Posted 4 years ago #

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

  6. Sculley
    Member
    Posted 4 years ago #

    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)?

  7. Sculley
    Member
    Posted 4 years ago #

    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?

  8. equalmark
    Member
    Posted 4 years ago #

    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.

  9. Sculley
    Member
    Posted 4 years ago #

    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.

  10. equalmark
    Member
    Posted 4 years ago #

    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.

  11. Sculley
    Member
    Posted 4 years ago #

    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.

  12. equalmark
    Member
    Posted 4 years ago #

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

  13. Sculley
    Member
    Posted 4 years ago #

    Where do I implement that?

    In the header.php?

  14. Sculley
    Member
    Posted 4 years ago #

    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.
    </div>

    And then style the nav_menu?

  15. equalmark
    Member
    Posted 4 years ago #

    A good starting point for wp_nav_menu is here:

    http://codex.wordpress.org/Function_Reference/wp_nav_menu

  16. Sculley
    Member
    Posted 4 years ago #

    Okay, thanks. Let me take a look.

  17. Sculley
    Member
    Posted 4 years ago #

    I've got it working for the most part.....any idea how to get it so that when you put your cursor over "Services" the drop downs won't overlap the word "Services" but just drop down?

    thestudio88.com

  18. Jorge
    Member
    Posted 4 years ago #

    any idea how to get it so that when you put your cursor over "Services" the drop downs won't overlap the word "Services" but just drop down?

    There are resources available online that all of us read, simply type a keyword and hit enter. The way it looks like, you're asking forum members to build your Website for you when your site claims to be professional Web site design whatever.

    Go over to http://codex.wordpress.org for all the resources we have used for research over the years. It's a good place to start. The same community members have spent countless hours updating the wiki for the community.

    When you search on Google for resourses, type the keyword like this:

    wp_list_pages site:codex.wordpress.org

    You'll be surprised how much information is available.

  19. Sculley
    Member
    Posted 4 years ago #

    Great. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.