certainlyakey
6/22/2014 - 9:32 PM

Simple breadcrumbs for Wordpress

Simple breadcrumbs for Wordpress

<ul class="breadcrumbs"><li>
	<?php 
	$parentposts = array_reverse( get_post_ancestors( $post->ID ) );
	$breadcrumbs_text = '';
	for ($i=0; $i < count($parentposts); $i++) { 
		$parentpost_title = get_the_title($parentposts[$i]);
		$parentpost_link = get_permalink($parentposts[$i]);
		if ($i > 0) {$breadcrumbs_text .= '<ul><li>';}
		$breadcrumbs_text .= '<a href="'.$parentpost_link.'">'.$parentpost_title.'</a>';
		if ($i > 0) {$breadcrumbs_text .= '</li></ul>';}
	}
	echo $breadcrumbs_text;
?>
</li></ul>