Breadcrumbs are used to show the process to which you would navigate to a page. For posts on your WordPress blog you can use breadcrumbs on your posts to show the categories which this post is in. Displaying what categories the post is in means you can add another link to the category so that if the visitor is interested in this category they can easily navigate to more posts on the subject.
So here below we have a little snippet that contain The function below the_breadcrumb()
will get the breadcrumbs for the current page this will need to go into the functions.php
page. Then later you have to call this function on your desired page where you want to show breadcrumbs but only on single page single.php
. So without any more preface, just garb the code now and go for it.
Table of Contents
Features:
1.) Pure PHP code.
2.) Have to edit function.php
and single.php
file.
3.) Add Breadcrumb on your all post page.
4.) Display Blog Name > All Categories there.
5.) Easy to use and fully customizable.
How To Secure Your WordPress Login Page Without Any Plugin?
Step 1:) Copy the below code and Paste in in your Theme Function(function.php) file.
/* ------------------------------------------------------------------------- * * Breadcrumb For Single Post /* ------------------------------------------------------------------------- */ function the_breadcrumb() { if (!is_home()) { echo '<a href="'; echo get_option('home'); echo '">'; bloginfo('name'); echo "</a> » "; if (is_category() || is_single()) { the_category(' / '); if (is_single()) { echo " » "; the_title(); } } elseif (is_page()) { echo the_title(); } } }
Step 2:) Now Copy the below code and Paste in your Single Page(single.php) file within the post loop anywhere you want to display the breadcrumbs.
< ?php the_breadcrumb(); ?>
Step 3:) Dave and done.
Customization:
You just have to add some CSS on it only. Rest all is done.
Theme Files Editing Warning:
Keep in mind that every code that you will add in your themes files will be removed when you will change the theme. So after changing your theme, you have to follow this article again and you will get everything back same as it is now.
Last Words:
This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.
Be the first to write a comment.