From 317b5a9cc105cecdd4efaf068753fef0e21e35f8 Mon Sep 17 00:00:00 2001 From: kjodle Date: Mon, 15 Feb 2016 20:22:59 -0500 Subject: [PATCH] Added descriptions to main menu --- functions.php | 33 +++++++++++++++++++++++++++++++++ header.php | 5 ++++- style.css | 7 +++++++ styles/menumaker.css | 2 +- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index dd17c8f..aad05d6 100644 --- a/functions.php +++ b/functions.php @@ -160,6 +160,39 @@ function atticus_finch_excerpt_more( $more ) { add_filter( 'excerpt_more', 'atticus_finch_excerpt_more' ); +// Add descriptions to main menu +// http://www.wpbeginner.com/wp-themes/how-to-add-menu-descriptions-in-your-wordpress-themes/ + +class Atticus_Finch_Menu_With_Description extends Walker_Nav_Menu { + function start_el(&$output, $item, $depth=0, $args = array(), $id=0) { + global $wp_query; + $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; + + $class_names = $value = ''; + + $classes = empty( $item->classes ) ? array() : (array) $item->classes; + + $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); + $class_names = ' class="' . esc_attr( $class_names ) . '"'; + + $output .= $indent . '