Empowering clients to take control of their websites

Editable menus in WordPress open up a-lot of opportunities for clients to really take control over even the most advanced menu systems. We make it even easier for clients by extending this core WordPress functionality with our own bespoke code.

Some of the key WordPress menu development tips from the presentation:

  • Be sure not to miss the ‘screen options’ (top right) in the WordPress menu admin area. This is how you reveal advanced options such as title attribute and CSS classes.
  • Think carefully about your menu area names – use logical naming conventions that are tied to context and content, rather than their physical position (which is likely to change or not make sense with adaptive responsive design layouts).
  • Investigate and understand the parameters of the wp_nav_menu() function – you can achieve some clever functionality just with these (such as ‘depth’, ‘echo’ and ‘fallback_cb’).
  • Don’t repeat menus – re-use them to make it easier for the client to manage them (‘depth’ parameter comes in very useful here!)
  • Use the core CSS classes output to highlight menu items (.current-menu-item) and open up unique styling opportunities (.menu-item-object-{posttype})
  • Re-using WordPress multisite menus is easy across a network of sites to avoid menu duplication and make client menu maintain easier – use switch_to_blog() and restore_current_blog() core Multisite functions.
  • There are lots of filters available to alter and change menu item output, search for ‘apply_filter’ in the wp-includes/class-walker-nav-menu.php file.
  • To extend menu output further create a custom menu walker that extends to core functionality. Don’t just duplicate the whole class, take advantage of the OOP structure of this core code to only create the methods (functions) that you need and these will be used instead.

Header photo courtesy of Phil Wylie – used under Creative Commons Attribution license (thank Phil!) – WordCamp Manchester 2016 Photostream from the conference.