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 . '
' . $item->description . '
'; + $item_output .= ''; + $item_output .= $args->after; + + $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id ); + } +} + /** * Implement the Custom Header feature. */ diff --git a/header.php b/header.php index b2180bd..f84fe09 100644 --- a/header.php +++ b/header.php @@ -78,6 +78,8 @@ + +