Create breadcrumb in php – PHP Breadcrumb

breadcrumb is useful for every site. here I explained code about Create breadcrumb in php – PHP Breadcrumb. This code will be helpful for website developers.

Create breadcrumb in php – PHP Breadcrumb

What are breadcrumbs?

How to create the breadcrumbs in wordpress

How to create the breadcrumbs in wordpress

Well quite simply, in web page terms this refers to a list of links (usually at the top) that appear on a web page to tell the user where they are in the structure of the website they are viewing. This makes navigating backward and forward so much easier as they have the ability to skip directly back through whole categories, rather than just using the browser’s back button.


The breadcrumbs.php include file:

Copy the code below, save it in a file called breadcrumbs.php and upload it to your site. This will print out a simple unordered list (<ul>) of the parent directories by directory name. The only edits you may wish to make to this file is to change the $ul_id='crumbs'; line if you wish to change the id of the <ul>. If you wish to add a background image or border etc to the <li> simply select it as #crumbs li{} and style. Script for Create breadcrumb in php:

echo '<ul id="'.$ul_id.'"><li><a href="/">Home</a></li>';
if($key > 1){
while($n < $key){
if($key < count($bc)-1) echo '<li><a href="'.$dir.'">'.$val.'</a></li>';
echo '<li>'.$pagetitle.'</li>';
echo '</ul>';</pre>
?> This is some more usefull code
echo $url;
echo "<br>";
$array = explode("/",$url);
echo $array[2]; ///which folder would you want to access ?
echo "size of array = ".sizeof($array)."<br>";

Use above script for Create breadcrumb in php.

A script to insert in the HTML where you want the breadcrumbs to appear:

Edit the URI to point to where you saved the include file (once this is done it never needs to be changed again). Edit, ‘Insert Page Title’ to add the page title to the end of the breadcrumbs.

$pagetitle="Insert Page Title";

Note: It would be useful to automatically print the page <title> as the last crumb but PHP cannot interrogate the DOM. Javascript would be required which we didn’t think appropriate as nothing would be returned if Javascript was turned off.

If you are looking for wordpress breadcrumbs then visit this link

wordpress breadcrumbs without any wp plugin


Add a Comment

Your email address will not be published. Required fields are marked *