How to Use Breadcrumbs On WordPress

[easy-social-share counters=0 style="button"]

Breadcrumbs are widely-used to display the method to which you simply would likely navigate to a webpage. For posts on your word press blog you can make use of breadcrumbs on your posts to display the different categories which this article shows.

Showing just what categories the post is in means you can insert a different url to the category so that if the site visitor is interested by this category they can simply navigate to a lot more posts on this subject.

The function below the breadcrumb ( ) will be able to get the breadcrumbs for the recent web page it will require to get into the functions.php web page.

<?php

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>';

}

?>

When this function was in the functions.php page you can easily call up this from any kind of page within the post loop.

Go into your a single.php page and then insert the following code just about anywhere show the breadcrumbs.

<?php the_breadcrumb(); ?>

Submit a comment

Pin It on Pinterest