From: Steve Sutton Date: Thu, 23 Jun 2016 20:08:20 +0000 (-0400) Subject: Update code X-Git-Tag: v1.0.0^2~26 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=7d8801458532d0ad2c0db87a2767763f019e73a6;p=WP-Themes%2Fcsrye.git Update code make sure only the first one is outputting the title --- diff --git a/lib/menu-walker.php b/lib/menu-walker.php index c7f2d74..75bfec8 100644 --- a/lib/menu-walker.php +++ b/lib/menu-walker.php @@ -17,17 +17,17 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu { } function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { - static $saveParent = 0; + static $saveParent = 0, $title = ''; $item_html = ''; parent::start_el( $item_html, $object, $depth, $args ); //echo '
$object: ' . print_r($object, true) . '
'; // Insert style to display page's thumbnail - $item_style = ''; if ( $depth == 0 ) { + $title = 0; $saveParent = $object; } - if ( $depth != 0 ) { + if ( !$title && $depth == 1 ) { // get the page title from parent $title = get_the_title( $saveParent->object_id ); $output .= '
  • ' . $title . '

  • '; @@ -41,9 +41,6 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu { if ( in_array( 'divider', $classes ) ) { $item_html = preg_replace( '/]*>( .* )<\/a>/iU', '', $item_html ); } - if ($item_style) { - $output .= $item_style; - } $output .= $item_html; }