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.

Is it best to hardcode a sidebar menu using functions.php or sidebar.php OR use the custom menu widget? Are there times when each is appropriate?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

To some degree, the answer depends on the intended use of the sidebar menu, but in general, it is best to allow the greatest degree of freedom to the end user.

If the intended use of the sidebar menu is to be, well, a navigation menu, then I would strongly recommend supporting the core Nav Menus feature. If the intended use of the navigation menu exceeds to functionality of the core feature, then you can always define a custom callback that will implement your advanced functionality.

I use this approach with my Oenology Theme. I have a sidebar menu that dynamically displays sub-menus of static Pages. One limitation of the core Nav Menu feature is that it is not dynamic. Every time the user adds a static Page, the user has to update the existing custom menu manually.

But, the way I implemented it was to define a theme_location for my sidebar menu, but defined my callback using wp_list_pages(), with custom arguments. That way, the default/fallback behavior is a dynamic menu, but the end user has the option to override the default behavior, if needing/wanting a custom menu.

share|improve this answer
    
Found this post as a great way to preset widget areas. themeshaper.com/2009/07/06/wordpress-theme-sidebar-template –  Christopher Ickes May 16 '12 at 13:22
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.