Breadcrumb is basically a navigation support used in software, websites or applications. It is an orderly set of links that denote a hierarchical path or trail within a website or software.

It is used to indicate to the user of his/her present location within the website or software with respect to the homepage or landing page. It is at times also referred to as “Breadcrumb Trail”.

Example: Home > WordPress > How To Add Breadcrumb

Add Breadcrumb to your WordPress template

It’s pretty simple to add a breadcrumb to your WordPress template. Follow the following steps.

Step 1
Add the following function into the functions.php file found within your WordPress template directory – like wp-content/themes/<yourthemename>/functions.php.

[sourcecode language=”php”]
function showbreadcrumb()
if (!is_home())
echo ‘<a href=”‘ . get_option(‘home’) . ‘”>’ . ‘Home’ . ‘</a> » ‘;

if(is_category() || is_single())
the_category(‘, ‘);
echo ” » “;
elseif (is_page())
{ echo the_title(); }
elseif (is_tag())
{ single_tag_title(); }
elseif (is_day())
{ echo”Archive for “; the_time(‘j F, Y’); }
elseif (is_month())
{ echo”Archive for “; the_time(‘F Y’); }
elseif (is_year())
{ echo”Archive for “; the_time(‘Y’); }
elseif (is_author())
{ echo”Author Archive”; }
elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’]))
{ echo “Blog Archives”; }
elseif (is_search())
{ echo”Search Results”; }

Step 2
Add the following line of code in any of the template file where you did like to show the breadcrumb. It’s recommended to place breadcrumb within the header.php file.

[sourcecode language=”php”]
// Show Breadcrumb

Now, refresh your WordPress website and you will have the breadcrumb displayed depending on the type of page being viewed – i.e. Page, Category, Archive, Search, Single Post, etc.

Did you face any problem during implementation?