Skip to content

Instantly share code, notes, and snippets.

@hsquareweb
Created June 5, 2012 18:15
Show Gist options
  • Select an option

  • Save hsquareweb/2876656 to your computer and use it in GitHub Desktop.

Select an option

Save hsquareweb/2876656 to your computer and use it in GitHub Desktop.
WP: Dynamic Breadcrumbs
<div id="breadcrumbs">
<a href="<?php echo get_bloginfo('url'); ?>" title="">Home</a>
<?php
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<a href="'.get_permalink($page->ID).'" title="'.get_the_title($page->ID).'">'.get_the_title($page->ID).'</a>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo ' / '.$crumb;
?>
</div>
<h1><?php the_title(); ?></h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment