Skip to content

Instantly share code, notes, and snippets.

@geoffduke
Created October 15, 2018 14:06
Show Gist options
  • Save geoffduke/c7464f3544aac37cffa50d0708e3544c to your computer and use it in GitHub Desktop.
Save geoffduke/c7464f3544aac37cffa50d0708e3544c to your computer and use it in GitHub Desktop.
Adding breadcrumb and side menus to WP_Themes
<!-- breadcrumb -->
<?php
$theParent = wp_get_post_parent_id(get_the_ID());
if ($theParent) { ?>
<div class="metabox metabox--position-up metabox--with-home-link">
<p><a class="metabox__blog-home-link" href="<?php echo get_permalink($theParent); ?>"><i class="fa fa-home" aria-hidden="true"></i> Back to <?php echo get_the_title($theParent); ?></a> <span class="metabox__main"><?php the_title(); ?></span></p>
</div>
<?php }
?>
<!-- side_menu Only appears if the page has child pages -->
<?php
$testArray = get_pages(array(
'child_of' => get_the_ID()
));
if($theParent or $testArray) { ?>
<div class="page-links">
<h2 class="page-links__title"><a href="<?php echo get_permalink($theParent); ?>"><?php echo get_the_title($theParent); ?> </a></h2>
<ul class="min-list">
<?php
if($theParent){
$findChildrenOf = $theParent;
}else{
$findChildrenOf = get_the_ID();
}
wp_list_pages(array(
'title_li' => NULL,
'child_of' => $findChildrenOf,
'sort_column' => 'menu_order'
));
?>
</ul>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment