Skip to content

Instantly share code, notes, and snippets.

@andyknapp
Last active December 24, 2015 07:39
Show Gist options
  • Save andyknapp/6764989 to your computer and use it in GitHub Desktop.
Save andyknapp/6764989 to your computer and use it in GitHub Desktop.
WordPress breadcrumbs
<?php
global $post; // first check if pg has parent
if ( is_page() && $post->post_parent ) { ?>
<section class="child-menu">
<?php
$parent_url = get_permalink($post->post_parent);
$parent_title = get_the_title($post->post_parent);
if ( $parent_url != the_title('', '', false) ) {
echo '<a class="sub-child" href='. $parent_url . '>' . $parent_title . '</a> <span>&raquo;</span> ';
}
?>
<span class="sub-child active-child" ><?php the_title(); ?></span>
</section>
<?php } else {
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment