This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Vertical Breadcrumb | |
* | |
* @package BE_Genesis_Child | |
* @since 1.0.0 | |
* @link https://github.com/billerickson/BE-Genesis-Child | |
* @author Bill Erickson <[email protected]> | |
* @copyright Copyright (c) 2011, Bill Erickson | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
* | |
*/ | |
echo '<div class="campl-tertiary-navigation"><ul class="campl-vertical-breadcrumb">'; | |
// Homepage | |
echo '<li><a href="' . home_url() . '">' . get_bloginfo( 'name' ) . '<span class="campl-vertical-breadcrumb-indicator"></span></a></li>'; | |
// Ancestors | |
$ancestors = array_reverse( get_post_ancestors( get_the_ID() ) ); | |
foreach( $ancestors as $ancestor ) | |
echo '<li><a href="' . get_permalink( $ancestor ) . '">' . get_the_title( $ancestor ) . '<span class="campl-vertical-breadcrumb-indicator"></span></a></li>'; | |
echo '</ul>'; | |
echo '<ul class="campl-vertical-breadcrumb-navigation">'; | |
// Sibling, Current and Children | |
global $post; | |
$current = $post->ID; | |
if( 0 !== $post->post_parent ) { | |
$args = array( | |
'post_type' => 'page', | |
'posts_per_page' => -1, | |
'post_parent' => $post->post_parent, | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'no_found_rows' => true, | |
'update_post_term_cache' => false, | |
'update_post_meta_cache' => false, | |
); | |
$siblings = new WP_Query( $args ); | |
if( $siblings->have_posts() ): while( $siblings->have_posts() ): $siblings->the_post(); | |
if( $current == get_the_ID() ) | |
be_vertical_breadcrumb_current(); | |
else | |
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>'; | |
endwhile; endif; wp_reset_postdata(); | |
} else { | |
// Current and Children | |
be_vertical_breadcrumb_current(); | |
} | |
echo '</ul></div>'; | |
/** | |
* Current and Children | |
* | |
*/ | |
function be_vertical_breadcrumb_current() { | |
// Current Page | |
echo '<li class="campl-selected"><a href="' . get_permalink() . '">' . get_the_title() . '</a>'; | |
// Children Pages | |
$args = array( | |
'post_type' => 'page', | |
'posts_per_page' => -1, | |
'post_parent' => get_the_ID(), | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'no_found_rows' => true, | |
'update_post_term_cache' => false, | |
'update_post_meta_cache' => false, | |
); | |
$children = new WP_Query( $args ); | |
if( $children->have_posts() ): | |
echo '<ul class="campl-vertical-breadcrumb-children">'; | |
while( $children->have_posts() ): $children->the_post(); | |
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>'; | |
endwhile; | |
echo '</ul>'; | |
endif; | |
wp_reset_postdata(); | |
echo '</li>'; | |
} | |