基于wpu navu菜单而不是页面结构的Wordpress面包屑
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于wpu navu菜单而不是页面结构的Wordpress面包屑相关的知识,希望对你有一定的参考价值。
Thanks to Stephen Harris for this > http://wordpress.stackexchange.com/questions/50425/show-current-navigation-path-from-menu
/* --- new walker class to create breadcrumb from nav menu structure using wp_nav_menu ------- use like: wp_nav_menu( array( 'container' => 'none', 'theme_location' => 'primary', 'walker'=> new bi_BreadCrumbWalker, 'items_wrap' => '<div id="breadcrumb-%1$s" class="%2$s">%3$s</div>' ) ); */ class bi_BreadCrumbWalker extends Walker{ /** * @see Walker::$db_fields * @var array */ /** * delimiter for crumbs * @var string */ var $delimiter = ' > '; /** * @see Walker::start_el() * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth, $args) { //Check if menu item is an ancestor of the current page $current_identifiers = array( 'current-menu-item', 'current-menu-parent', 'current-menu-ancestor' ); if( $ancestor_of_current ){ $title = apply_filters( 'the_title', $item->title, $item->ID ); //Preceed with delimter for all but the first item. if( 0 != $depth ) $output .= $this->delimiter; //Link tag attributes //Add to the html output //$output .= '<a'. $attributes .'>'.$title.'</a>'; // added by me to remove the link on the current page item $output .= '<span class="current-page">'.$title.'</span>'; } else { $output .= '<a'. $attributes .'>'.$title.'</a>'; } } } }
以上是关于基于wpu navu菜单而不是页面结构的Wordpress面包屑的主要内容,如果未能解决你的问题,请参考以下文章
功能para personalizer wpu navu menu()