I am stuck on how to create a breadcrumb menu in my wordpress so that when I select the main menu, the path shows its first inner menu. For example I have a main menu About us and Company Profile as its child. When I am select the About us, I want to get the Compony profile page and also the breadcrumb like About us / Company profile. Is there any way to do so? any plugins? I currently using Breadcrumb NavXT plugin for creating breadcrumb
0
votes
1 Answers
0
votes
You can add breadcrumb without using any plugin like this. Please add below code into your themes functions.php file.
function breadcrumbs($id = null){
?>
<div id="breadcrumbs">
<a href="<?php bloginfo('url'); ?>">Home</a></span> >
<?php if(!empty($id)): ?>
<a href="<?php echo get_permalink( $id ); ?>" ><?php echo get_the_title( $id ); ?></a> >
<?php endif; ?>
<span class="breadcrumb_last"><?php the_title(); ?></span>
</div>
<?php }
Now whenever you want to add breadcrumb just call this function like this.
<?php breadcrumbs(); ?>
As you mentioned above you have to add about page id into this function and call this to company profile page if this page is child page of about page than this works.
<?php breadcrumbs($id); ?>