Skip to content
  • Homepage
  • HTML
  • CSS
  • Symfony
  • PHP
  • How to
  • Contact
  • Donate

Teach Developer

Articles, Guides & Tips

How to Display Breadcrumb without Plugin in WordPress

Home  »  How to • Wordpress   »   How to Display Breadcrumb without Plugin in WordPress
Posted on September 3, 2022September 17, 2022
1,239

Breadcrumbs are navigation links, used to display links to all pages beyond the homepage. By default, it is placed at the top of the page and helps in back navigation. In WordPress, breadcrumbs play an important role on the posting page. There are many WordPress plugins available to add breadcrumbs to your site. But we recommend you use our simple code to display breadcrumbs on your WordPress site.

You can easily display breadcrumb on WordPress sites without any plugin. In this tutorial, we’ll show you how to create and display breadcrumbs in WordPress.

We’ve created a custom function called get_breadcrumb() to generate the breadcrumb links. You only need to add the get_breadcrumb() function code in functions.php the file of the current theme.

/**
 * Generate breadcrumbs
 * @author teachdeveloper
 * @authorURL www.teachdeveloper.com
 */
function get_breadcrumb() {
    echo '<a href="'.home_url().'" rel="nofollow">Home</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>"';
    }
}

Display Breadcrumbs:

Call the get_breadcrumb() function in single.php file and others files where you want to display the breadcrumbs on your WordPress site.

<div class="breadcrumb"><?php get_breadcrumb(); ?></div>

Styling Breadcrumbs:

This CSS helps to style the breadcrumbs links.

.breadcrumb {
    padding: 8px 15px;
    margin-bottom: 20px;
    list-style: none;
    background-color: #f5f5f5;
    border-radius: 4px;
}
.breadcrumb a {
    color: #428bca;
    text-decoration: none;
}
How to, Wordpress Tags:PHP

Post navigation

Previous Post: How to Search Recently Modified Files in Linux
Next Post: How to Add Reset Button in jQuery UI Datepicker

Related Posts

  • How to Enable Debug Mode in Laravel
  • How to Add Reset Button in jQuery UI Datepicker
  • How to trigger a button click from another button click event with JavaScript?
  • How to use events listeners and Event Subscriber in Symfony
  • How to Create Live Search in HTML table with jQuery
  • How to use :hover to modify the CSS of another class?

Categories

  • Codeigniter (3)
  • CSS (11)
  • eCommerce (1)
  • Framework (1)
  • Git (3)
  • How to (43)
  • HTML (5)
  • JavaScript (15)
  • Jquery (7)
  • Laravel (1)
  • Linux (4)
  • Magento-2 (1)
  • Node js (4)
  • Others (2)
  • PHP (11)
  • React (13)
  • Server (1)
  • SSH (3)
  • Symfony (6)
  • Tips (16)
  • Top Tutorials (10)
  • Ubuntu (3)
  • Vue (1)
  • Wordpress (7)

Latest Posts

  • What is SSH in Linux?
  • How to Delete Files in Ubuntu Command Line
  • How to Deploy a React application on a cPanel
  • How to use events listeners and Event Subscriber in Symfony
  • How to Convert PHP CSV to JSON

WEEKLY TAGS

AJAX (1) Codeigniter (1) Javascript (11) JQuery (1) PHP (16) Programming (1) React (3) Symfony (1)

Random Post

How to check PHP version using the command line
How to display the last updated date of a post in WordPress
Dealing with deprecations
How to split a string into an array with Twig
Difference Between Git and GitHub

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved