fbpx
How to Show WordPress Breadcrumbs Without Using a Plugin

How to Show WordPress Breadcrumbs Without Using a Plugin

This snippet will let you create breadcrumbs on your WordPress site without using any plugins.

Instructions
Add the following to your functions.php file.

function the_breadcrumb() {
     echo '<ul id="crumbs">';
	if (!is_home()) {
		echo '<li><a href="';
		echo get_option('home');
		echo '">';
		echo 'Home';
		echo "</a></li>";
		if (is_category() || is_single()) {
			echo '<li>';
			the_category(' </li><li> ');
			if (is_single()) {
				echo "</li><li>";
				the_title();
				echo '</li>';
			}
		} elseif (is_page()) {
			echo '<li>';
			echo the_title();
			echo '</li>';
		}
	}
	elseif (is_tag()) {single_tag_title();}
	elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
	elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
	elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
	elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
	elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
	elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
	echo '</ul>';
}

To display the menu, add this syntax to your template files where you want to display the breadcrumbs:
<?php the_breadcrumb(); ?>

WordPress Snippet Info

Tested with Wordpress v. NA
Review Status: Needs Review

How to Show WordPress Breadcrumbs Without Using a Plugin
4.5 (89.52%) 21 vote[s]
Please report broken snippets.
Report Broken Snippet