What are WordPress Breadcrumb?

11
1.3K followers
Updated

Wikipedia defines a breadcrumb as follows:

The graphical control element Breadcrumbs or breadcrumb trail is a navigation aid used in user interfaces. It allows users to keep track of their locations within programs or documents. The term comes from the trail of breadcrumbs left by Hansel and Gretel in the popular fairytale.

On websites that have a lot of pages, breadcrumb navigation can greatly enhance the way users find their way around. In terms of usability, breadcrumbs reduce the number of actions a website visitor needs to take in order to get to a higher-level page, and they improve the findability of website sections and pages. They are also an effective visual aid that indicates the location of the user within the website’s hierarchy, making it a great source of contextual information for landing pages.

Unfortunately plugins for simple functions within a WordPress installation are too often used. To answer to control this shortcoming, or perhaps rather the laziness a bit, I'm just doing my blogs to extract the juice a little and make plug-in free. In the following you’ll find a code that you can copy in your theme’s functions.php, that will generate a breadcrumb very simple and that you can use on any page (single.php, archiv.php etc.).

Modify your theme files only when you have some experience in Html and css coding, otherwise choose a theme with integrated breadcrumbs or use the below recommended plug in.

To integrate our new breadcrumb feature in our WordPress theme, you proceed as follows:

Modify the first functions.php

You go to appareance>Editor and open the functions.php and just copy the following code to the file:

<?php

function the_breadcrumb() {

global $post;

echo '<ul id="breadcrumbs">';

if (!is_home()) {

echo '<li><a href="';

echo get_option('home');

echo '">';

echo 'Home';

echo '</a></li><li class="separator"> / </li>';

if (is_category() || is_single()) {

echo '<li>';

the_category(' </li><li class="separator"> / </li><li> ');

if (is_single()) {

echo '</li><li class="separator"> / </li><li>';

the_title();

echo '</li>';

}

} elseif (is_page()) {

if($post->post_parent){

$anc = get_post_ancestors( $post->ID );

$title = get_the_title();

foreach ( $anc as $ancestor ) {

$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>';

}

echo $output;

echo '<strong title="'.$title.'"> '.$title.'</strong>';

} else {

echo '<li><strong> '.get_the_title().'</strong></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>';

}

?>

Then add to your header.php following code :

<?php the_breadcrumb(); ?>

Then add this to your Stysheet.css

#breadcrumbs{

list-style:none;

margin:10px 0;

overflow:hidden;

}

#breadcrumbs li{

float:left;

margin-right:15px;

}

#breadcrumbs .separator{

font-weight:700;

font-size:20px;

color:#999;

}

But for those of you who prefer not to go and change the files of your thème, there are some very good plugins like:

Breadcrumb NavXT -

https://wordpress.org/plugins/breadcrumb-navxt/

Login
Create Your Free Wealthy Affiliate Account Today!
icon
4-Steps to Success Class
icon
One Profit Ready Website
icon
Market Research & Analysis Tools
icon
Millionaire Mentorship
icon
Core “Business Start Up” Training

Recent Comments

24

Thank you for the information and coding. I am still learning how to use html coding but I'm slowly starting to understand.

Html and CSS are languages as others, but it is really not necessary to know to move forwards in Internet Marketing.

Thank you giludi, I will bookmark this for reference.
All the best,
Brandon

Thanks for you support. But please use a plugin if you don't have any experience in html - css coding.

thanks! I used the plugin!

this is mostly the best solution.

Interesting. Thank you for sharing.

thanks for your support.

I bookmark you for when I am a bit more certain from what I am doing, for now I stay away from editor stuff, I don't trust myself in that area yet, Loes

better don't touch at codes until you learned about. Use the plugin, it's mostly safer.

If you would like this topic explained in plain English here is my blog post on breadcrumbs for WordPress

https://my.wealthyaffiliate.com/bazboy247/blog/bread-crumbs-in-plain-english

Barry

yes, my friend.

I've been wondering about breadcrumbs for a while. Thanks for the illumination.

Great posting, Gliudi...

You have a deep insight in this field and its kind of you share your unique knowldege with the Community.

Thank you for all you do,
Jay Barnelli

Thanks for your support.

First I've ever heard of it and can't say I understand it, but. . . I appreciate the share, Guy, and will refer back to it if/when I need to. Looks like excellent information.

you know in Interrnet marketing and website building, ther's so much to learn.

VERY true!

Thanks s much for the post. It shares plenty of light on the topic of bread crumbs

thanks for reading.

See more comments

Login
Create Your Free Wealthy Affiliate Account Today!
icon
4-Steps to Success Class
icon
One Profit Ready Website
icon
Market Research & Analysis Tools
icon
Millionaire Mentorship
icon
Core “Business Start Up” Training