Added descriptions to main menu

This commit is contained in:
kjodle 2016-02-15 20:22:59 -05:00
parent 22f8139f2e
commit 317b5a9cc1
4 changed files with 45 additions and 2 deletions

View File

@ -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 . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '<p class="sub">' . $item->description . '</p>';
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
}
}
/**
* Implement the Custom Header feature.
*/

View File

@ -78,6 +78,8 @@
<?php do_action( 'atticus_finch_before_primary_menu' ); ?>
<?php $walker = new Atticus_Finch_Menu_With_Description; ?>
<nav id="primary-menu">
<?php wp_nav_menu( array(
'theme_location' => 'primary-menu',
@ -86,7 +88,8 @@
'menu_id' => 'belowheadermenu-ul',
'container' => 'div',
'container_id' => 'belowheadermenu',
'depth' => 3
'depth' => 3,
'walker' => $walker,
) );
?>
<div class="clear"></div>

View File

@ -158,6 +158,13 @@ nav#primary-menu {
font-size: 14px;
}
p.sub { /* Style main menu descriptions */
font-family: serif;
margin: 0.3em 0 0 0;
font-weight: normal;
font-style: italic;
}
/**********************************/
/* 4. #content Elements */

View File

@ -481,7 +481,7 @@
right: 0;
}
#belowheadermenu li:hover > ul > li {
height: 35px;
height: 55px;
}
#belowheadermenu ul ul ul {
margin-left: 100%;