Breadcrumbs is very useful in navigation. It is defined as a navigation technique that offers link to the home page to the user navigated through to arrive at the current post/page.There are so many plugins that is used to add breadcrumbs in wordpress. But more plugins slows down the site loading speed and also its quite insecure too for wordpress website.
We can add breadcrumbs by adding some code in wordpress theme functions.php .
Paste this code into your theme's 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>';
}
After adding the code in functions.php , you can call it anywhere in header.
For calling breadcrumbs just paste the below code where you want to call breadcrumbs.
You can add it basically above title tag
<?php the_breadcrumb(); ?>
0 Comment(s)