I have limited space for horizontal category navigation bar on top of my theme and I need to limit number of categories shown on this bar and tell WordPress put “More..” as a drop down menu link at the end of the list to let users hover their mouse cursors on that to see other categories as shown in screenshot.
How can I do that?
Depends on what function you’re using to format the navigation menu. It’s probably
wp_list_categories()
which might not be the best choice in your case. As @Andre mentioned in his answer, you might want to go with navigation menus available since WordPress 3, but if you need to stick to categories, tryget_categories()
which will return the categories in a non-formatted way. This will enable you to loop through them in any way that you want, include a counter to limit the general output, and then loop through the rest under the More submenu.Reference: get_categories
I guess you are using wordpress version 3+.
This is probably not the cleanest way but should work:
However, I’m not sure if you want the ‘More..’ menu item to be a linkpage/category. All of that is possible, just add the category/page instead of the ‘Custom Link’.
Hope this workaround can solve your problem.