2

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?

1 Answer 1

2

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.