Add Breadcrumbs to WordPress Without a Plugin
SHARE THIS

Breadcrumbs are a great way to give people a perspective of where they are on your site. In this post I will explain how to add breadcrumbs to WordPress without using a plugin. Adding this feature will also help the search engine spiders to find the structure of your site and decrease the time it takes to index a single page. A lot of wordpress theme developers like to use as few plugins as possible and this code will help you accomplish that.

[php]
<div class="breadcrumbs">

<?php

function breadcrumbs() {

$theFullUrl = $_SERVER["REQUEST_URI"];

$urlArray=explode("/",$theFullUrl);
echo ‘You Are Here: <a href="/">Home</a>’;

while (list($j,$text) = each($urlArray)) {
$dir=";
if ($j > 1) {
$i=1;
while ($i < $j) {
$dir .= ‘/’ . $urlArray[$i];
$text = $urlArray[$i];
$i++;
}
if($j < count($urlArray)-1) echo ‘ &raquo; <a href="’.$dir.’">’ . str_replace("-", " ", $text) . ‘</a>’;
}
}
echo wp_title();
}
breadcrumbs();
?>
</div>
[/php]

To include Breadcrumbs in your theme simply place the following where you need them:

[php]
<?php include ( TEMPLATEPATH . ‘/breadcrumbs.php’); ?>
[/php]

You can do the same by creating a function in your functions.php file and then calling the function in your theme.

Using the css class “breadcrumbs” you can style the results to easily blend in with your current theme.

.via { egrace creative }

1000s Template Choices for Your Site - From $5