How to create breadcrumbs in wordpress

wordpress breadcrumbs without wordpress plugin

Breadcrumbs are very common requirement of any wordpress sites. Many clients demands for breadcrumbs for there website. There are many many wordpress plugins available for breadcrumbs but I suggest not to use the wp plugin for breadcrumbs. Because these plugin will add the extra sql queries and load to your website.

All pages are linked for easy backwards navigation. Typically this is placed near the top of a web page. So for example, if you look to the top of this page you will see the breadcrumb navigation menu that leads a path back to the homepage.

wordpress breadcrumbs without wordpress plugin

How to create the breadcrumbs in wordpress
How to create the breadcrumbs in wordpress

Here’s ready code snippet to add wordpress breadcrumbs without wordpress plugin to your WordPress blog. Open your functions.php which you can find in your wordpress theme folder. and then just copy paste the code below in it:

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>';
}

Once done, open your header.php file which you can find in your theme folder and call the above function:

<?php the_breadcrumb(); ?>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.