Skip to content

Instantly share code, notes, and snippets.

@alkrauss48
Created March 14, 2015 21:01
Show Gist options
  • Save alkrauss48/9eddc3b74d88418f6460 to your computer and use it in GitHub Desktop.
Save alkrauss48/9eddc3b74d88418f6460 to your computer and use it in GitHub Desktop.
Easy breadcrumbs in wordpress
<aside class="breadcrumbs">
<?php the_breadcrumb(); ?>
</aside>
<?php
function the_breadcrumb() {
$anc = get_post_ancestors( $post->ID );
for($i = count($anc) - 1; $i >= 0; $i--){
echo "<a href=" . get_permalink($anc[$i]) . ">" . get_the_title($anc[$i]) . "</a>";
}
echo "<a href=" . get_permalink() . ">" . get_the_title() . "</a>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment