How to Add Breadcrumb Navigation in WordPress

September 11, 2025
How to Add Breadcrumb Navigation in WordPress

Breadcrumb navigation is a trail of links that shows visitors where they are on your site (for example: Home → Blog → Category → Post Title). It improves usability, helps with SEO, and reduces bounce rate by guiding users to higher-level pages. Here’s how to add breadcrumbs to your WordPress site.


Method 1: Add Breadcrumbs with Code (No Plugin)

You can build a simple breadcrumb trail directly into your theme. Add this function to your functions.php (or a custom plugin):

<?php
function my_breadcrumbs() {
    if ( is_front_page() ) return;

    echo '<nav class="breadcrumbs"><a href="' . home_url() . '">Home</a>';

    if ( is_category() || is_single() ) {
        echo " &raquo; ";
        the_category( ', ' );
        if ( is_single() ) {
            echo " &raquo; ";
            the_title();
        }
    } elseif ( is_page() ) {
        global $post;
        if ( $post->post_parent ) {
            $ancestors = array_reverse( get_post_ancestors( $post->ID ) );
            foreach ( $ancestors as $ancestor ) {
                echo ' &raquo; <a href="' . get_permalink( $ancestor ) . '">' . get_the_title( $ancestor ) . '</a>';
            }
        }
        echo " &raquo; " . get_the_title();
    } elseif ( is_search() ) {
        echo " &raquo; Search results for: " . get_search_query();
    } elseif ( is_404() ) {
        echo " &raquo; Error 404";
    }

    echo '</nav>';
}
?>

Now, insert the breadcrumbs where you want them to appear (commonly in header.php or single.php):

<?php if ( function_exists( 'my_breadcrumbs' ) ) my_breadcrumbs(); ?>

Method 2: Use a SEO Plugin (Easy Setup)

SEO plugins often include breadcrumb functionality:

  • Yoast SEO: Enable under Search Appearance → Breadcrumbs, then add <?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?> in your theme.
  • Rank Math: Enable under General Settings → Breadcrumbs and insert their provided function or shortcode.
  • All in One SEO: Similar built-in breadcrumb option with shortcode and template tags.

These plugins provide more advanced features like schema markup (SEO benefit), customizable separators, and design settings.


Method 3: Use a Dedicated Breadcrumb Plugin

If you don’t use an SEO plugin, you can install a lightweight breadcrumb plugin:

After activating, configure settings in the dashboard and place the provided template tag or shortcode into your theme.


Styling Breadcrumbs with CSS

Regardless of method, you can style breadcrumbs with CSS:

.breadcrumbs {
  font-size: 14px;
  margin: 0 0 20px;
}
.breadcrumbs a {
  color: #0073aa;
  text-decoration: none;
}
.breadcrumbs a:hover {
  text-decoration: underline;
}
.breadcrumbs span,
.breadcrumbs .current {
  color: #555;
}

Best Practices

  • Keep it clear: Use simple separators like “→” or “»”.
  • Start with Home: Always include a link back to your homepage.
  • Enable Schema: For SEO benefits, use a plugin that outputs schema markup.
  • Responsive design: Make sure breadcrumbs don’t overflow on small screens.

Summary

  1. Use a custom PHP function in your theme for lightweight breadcrumbs.
  2. Enable breadcrumb features in SEO plugins like Yoast or Rank Math for advanced options.
  3. Style breadcrumbs with CSS to match your site’s design.

Adding breadcrumb navigation improves user experience, makes your site easier to navigate, and provides search engines with useful structured data.

Avatar

Written by

satoshi

I’ve been building and customizing WordPress themes for over 10 years. In my free time, you’ll probably find me enjoying a good football match.