Archived

This topic is now archived and is closed to further replies.

  • 0

Dropdown menu list includes top level page

Question

Posted · Report post

I'm trying to accomplish what I think is a common piece of functionality for my site, but surprisingly can't find any mention how to do it. I want to customize my dropdown menu so it includes the top level page as the first item. For example: from: About us -> Board -> Contact Us -> Directions to: About us -> About us -> Board -> Contact Us -> Directions Can this be done with an addition to the header.php? I am using EcoPro. <www.sustainablelafayette.org> thanks in advance, Michael

Share this post


Link to post
Share on other sites

5 answers to this question

Posted · Report post

It's possible. Go to the header.php file and look for this code:

<?php wp_list_pages('sort_column=menu_order&depth=0&title_li=&link_before=<span>&link_after=</span>'); ?>
(This controls the dropdown menu) Replace the code above with this code and then save the file:
<?php wp_list_pages('include=2,423,240,307,18,111&sort_column=menu_order&depth=0&title_li=&link_before=<span>&link_after=</span>'); ?>

(The numbers 2, 423, 240, 307, 18, and 111 are the page IDs for the top level pages)

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks for the quick reply. I did the above, including substituting the page IDs for all the top level pages, and there seems to be no change in behavior: www.sustainablelafayette.org Is there anything else I need to do? Thanks again.

Share this post


Link to post
Share on other sites

Posted · Report post

Hm, it's probably not adding the top level links in the submenu because they're technically already displayed as menu links. One option is to create, for example, a subpage for "About Us" and that will result in the page being added as a subpage to the menu automatically. The problem with that is that there is already a parent page called "About Us", so it'd be repetitive. Another option is to re-work the navigation menu manually, which can allow you to add the subpages you want to the submenus, but that it must be edited manually every time you add, take away, or change page links. Which option do you prefer? Also, do you want to apply the change to all of the submenus or just one?

Share this post


Link to post
Share on other sites

Posted · Report post

You could do it by creating a second [About Us] page under the top [About Us] category, then use a 301 redirect plugin to open the sub-category [About Us] page when the top level link is clicked.

Share this post


Link to post
Share on other sites

Posted · Report post

Bingo. The 301 redirect plug in works perfectly. So clean and simple without multiple pages to keep consistent or messy javascript reloads. Thanks Murray and Catrina!

Share this post


Link to post
Share on other sites