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'm building a website in which there is a navigation menu with various links; in this menu there is the link to the blog section. My goal is to create a drop down menu that appears when the cursor is passed over the blog link; this link has to show the list of the categories.

A few days ago I found this useful tutorial:
http://wphacks.com/how-to-make-categories-drop-down-menu/

But it creates another link called "Categories" in which appears the categories drop down menu; therefore how can I adapt that code in my case?

Thanks!

share|improve this question
add comment

1 Answer

You have to modify only the first part as this:

<ul id="nav" class="clearfloat">
<li class="cat-item"><a href="<?php echo get_option('home'); ?>/" class="on"><?php echo get_option('blogname'); ?></a>
<ul class="children">
<?php wp_list_categories('orderby=name&title_li=');
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
?>
</ul>
</li>
<?php wp_list_pages('title_li='); ?>
</ul>

Here the menu will show up when you pass the cursor over the name of the blog that will be the first entry of the menu. If you want to show "home" and not the blog name just substitute

<?php echo get_option('blogname'); ?>

with

Home

If you want to show up not in the menu but in the logo of your blog page, just leave the menu code as the original one in wordpress, and substitute the code of the link you want to add the menu with this:

<ul id="nav" class="clearfloat">
    <li class="cat-item"><a href="<put here the old reference of the link you are substituting>/" class="on"><put here the old content (maybe an image?, everything you found between the a>xxx<\a> tags) of the link you are substituting></a>
    <ul class="children">
    <?php wp_list_categories('orderby=name&title_li=');
    $this_category = get_category($cat);
    if (get_category_children($this_category->cat_ID) != "") {
    echo "<ul>";
    wp_list_categories('orderby=id&show_count=0&title_li=
    &use_desc_for_title=1&child_of='.$this_category->cat_ID);
    echo "</ul>";
    }
    ?>
    </ul>
    </li>
    </ul>

Hope this helps, Marco

share|improve this answer
    
Thanks for the response! I'll try and I'll let you know if it works. –  DamianFox Jul 27 '13 at 10:26
    
I have tried to use your code but every link in the navigation bar disappear except the one that show the drop down menu. –  DamianFox Jul 27 '13 at 14:11
    
For the second one is correct, for the first one you should visualize avery link, if you want all the links just add <?php wp_list_pages('title_li='); ?> before the last </ul> –  Marco Romanoni Jul 31 '13 at 8:57
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.