WordPress Breadcrumbs — How To Create Breadcrumbs Without A WordPress Plugin

Breadcrumbs or breadcrumb trail is a navigation aid used in user interfaces. It allows users to keep track of their locations within a website. Especially when the website consists of a complex and deep-rooted hierarchy, breadcrumbs come in handy to display the exact navigation path to the specific web page.Thus breadcrumb trail is an indispensable element on websites which have a lot of pages. Navigation via breadcrumbs proves to be an effective way for smoothly navigating back and forth from one page to other.

For instance, instead of clicking the back button repeatedly to move to a higher level page, you can use breadcrumbs to navigate to Home page or any other page with just a click. Breadcrumb trail compliments and enhances the user experience. It’s fairly simple to add breadcrumbs to your WordPress powered website.Just place the following code in custom_functions.php to implement breadcrumbs without any plugin.

 
function custom_breadcrumbs()
{
         echo '<a href="'; 
         echo get_option('home');
         echo '">';
         bloginfo('name'); 
         echo "</a>";
         if (is_category() || is_single())
         { 
            echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
            the_category(' &bull; '); 
            if (is_single())   
            {  
             echo " &nbsp;&nbsp;&#187;&nbsp;&nbsp; "; 
             the_title(); 
            }
         }
         elseif (is_page())
         {
            echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
            echo the_title();
         }
         elseif (is_search())
         {
             echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;Search Results for... ";
             echo '"<em>';
             echo the_search_query();
             echo '</em>"';
          }
}

add_action('thesis_hook_before_post_box','custom_breadcrumbs');

What are you waiting for? Just snap the code and create the breadcrumb trail to ease the navigation on your website.

Divi WordPress Theme