Easy Breadcrumbs

Some themes or sites are well branched and navigation may go deeper than 2 levels only. In such cases building nested list of categories/subcategories (or pages/subpages) may look silly but in the same time 100% functional. Honestly, I’m not a fan of displaying mini site-map either in sidebar or drop-down so building sequential navigation in conjuction with breadcrumbs would be much more elegant solution.

I guess building sequential navigation will be the subject of another tutorial, right now we’ll stay focused on breadcrumbs only.

What are breadcrumbs? These are nothing but a road map of your site. They will help visitor to navigate easily and not allow to make him lost. Just take a look above the title of this article and everything will be clear enough.


<?php
	//where are we now?
	$categ_sp = get_the_category();
	//are there any parent categories?
	$my_parents = get_category_parents( $categ_sp[ 0 ]->cat_ID, TRUE, ',' );
	$arr_parents = explode( ',', $my_parents );
	//remove the last empty one if any
	array_pop( $arr_parents );
	if( count( $arr_parents ) > 1 ) {
		echo '<div id="breadcrumbz">';
		echo '<ul>';
		echo '<li><a href="' . get_option( 'home' ) . '">Home</a> &nbsp; &gt;</li>';
		$x = 0;
		while( $x < count( $arr_parents ) ) {
			echo '<li>' . $arr_parents[ $x ] . ' &nbsp; &gt;</li>';
			$x ++;
		}
		//for a case we are currently reading single article display title, not as a link
             if( is_single() ) echo '<li>' . get_the_title() . '</li>';
		echo '</ul>';
		echo '</div>';
	}
?>

Share with others...

deliciousdiggreddittechnoratifacebooktwittergoogleyahoowikioblinklistsimpyspurl
Comments (0)

Track comments via RSS 2.0 feed. Feel free to post the comment, or trackback from your web site.

Currently there are no comments related to article "Easy Breadcrumbs". You have a special honor to be the first commenter. Thanks!

Leave a Comment

Search

Stay in touch!

Subscribe Subscribe to RSSStay up to date with my blog

Twitter Follow me!Follow me or get followed

iPadCaseDen.com iPadCaseDen.comiPad cases, folio cases and bags review

Advertisement

GraphicRiver ThemeForest