How to add Breadcrumbs without plugins on WordPress
Most of the blog with SEO considerations using breadcrumbs. In this article I am going to show you how to do proper, full breadcrumbs in including nested categories and nested pages. Breadcrumbs are a pretty standard design pattern and can be very useful in a lot of website situations. For WordPress users typically use plugins. But for those who want to add facilities in bredacrumbs WordPress-based blog without using plugins, try my way below.
You can just include this function in your theme’s “functions.php” file.
function get_wp_breadcrumbs() {
if (!is_home()) {
echo ('You are here: ');
echo '<a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a> » ";
if (is_category() || is_single()) {
the_category(' » ',multiple);
if (is_single()) {
echo " » ";
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
else {
echo ('You are here: ');
echo '<a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a> » ";
}
}
And then add the following code in the “header.php” file.
<?php get_wp_breadcrumbs(); ?>
So there you have it. Fully customizable, valid breadcrumbs in WordPress. Please let me know what you think.