December 12, 2016 · admin

How to Add Subcategory to Breadcrumbs

How to Add Subcategory into Breadcrumbs

Category Missing in Breadcrumbs?

If you use a multi-category taxonomy for your posts, you might face a similar problem: WordPress does not include subcategory into the breadcrumbs at all (Picture 1). It is not a theme-specific issue but a general behaviour of WordPress. To fix this, you can use one of these two plugins which will help you include subcategory in breadcrumbs:

  1. Yoast SEO Plugin – you can configure the breadcrumbs in SEO – Advanced section in your WordPress menu.
  2. Breadcrumb NavXT – we will use this plugin in the article below.

Both of them require inserting the breadcrumbs into your theme PHP file. There are some plugins out which do not require this step, I have tried them and none of them worked properly with my configuration.

Installing and Configuring Breadcrumb NavXT

[info_list icon_bg_color=”#ef4836″ icon_color=”#ffffff” font_size_icon=”15″][info_list_item list_title=”Adding Code into Your Theme’s PHP File” list_icon=”Defaults-chevron-right”]After installing and activating the Breadcrumb navXT plugin, you need to insert these lines of code into your theme’s php file. Typically, it could be either header.php or single-header.php, header-single.php, post-header.php or similar. In my case, it is called header-single.php. Here, I inserted these lines at the end of the file:

<div class=”breadcrumbs” typeof=”BreadcrumbList” vocab=”http://schema.org/”>
<?php if(function_exists(‘bcn_display’))
{
bcn_display();
}?>

After inserting, the code appeared in the top left corner above my post heading (Picture 2).[/info_list_item][info_list_item list_title=”Fixing the Looks of the Breadcrumbs” list_icon=”Defaults-chevron-right”]As you can see from Picture 1, subcategories are displayed by default in the breadcrumbs. However, we need to fix the looks to make it similar to the original breadcrumbs that were styled by the theme. We need to change the font colour, font size, align the breadcrumbs to the centre and adjust the spaces around it to make it more compact. We achieved the desired effect by adding these lines to the style.css (you should use your child theme’s style.css file):

/*——- NavXT Breadcrumbs Styling ——- */
div.breadcrumbs {
padding-top: 20px;
font-family: Roboto;
font-size: 14px;
color: #444444;
text-align: center;
margin-bottom: -15px;
}

You can edit the style.css directly from your WordPress installation by navigating to Appearance – Editor. After applying this styling and refreshing, the looks of the breadcrumbs is very similar to the original ones (Picture 3).[/info_list_item][info_list_item list_title=”Renaming Home in Breadcrumbs and Removing Post Title” list_icon=”Defaults-chevron-right”]There are two other issues that need to be solved. The first is replacing the complete title of homepage by simple “Home”. To achieve this, go to Breacrumb NavXT settings, tab General and replace the “%htitle%” string in Home Template with “Home”.

You might also want to replace the default small arrow used as a separator by something like we have, just replace the “&gt;” default value in Breadcrumb Separator under General tab with ”  /  “.[/info_list_item][info_list_item list_title=”Hiding Breadcrumbs on Selected Pages” list_icon=”Defaults-chevron-right”]You might want to hide breadcrumbs on selected pages. This can be fixed by modifying the code we inserted into header-single.php in the first step. Replacing the code by this will ensure that breadcrumbs are hidden on homepage and two other pages (About Us and Website). Just use your aliases to designate those pages and feel free to add more of them using this syntax:

<div class=”breadcrumbs” typeof=”BreadcrumbList” vocab=”http://schema.org/”>
<?php if(function_exists(‘bcn_display’) && !is_front_page() && !is_page(‘about-us’) && !is_page(‘website’))
{
bcn_display();
}?>
</div>[/info_list_item][/info_list]

Breadcrumbs for Pages and Taxonomies

You can configure many other options in Breadcrumb NavXT settings, you will surely figure it out. No more coding or styling knowledge should be needed to further adjust it.

Catnapweb - Customised Breadcrumbs with Subcategory - Original WordPress Breadcrumbs
Picture 1: Default WordPress breadcrumbs inserted by your theme do not include subcategory
Customised Breadcrumbs with Subcategory - New Breadcrumbs Inserted Before Styling
Picture 2: After installing and activating the plugin and inserting the code into your post header php file, the breadcrumbs are displayed in your post detail
Customised Breadcrumbs with Subcategory - New Breadcrumbs Styled
Picture 3: New breadcrumbs including subcategory after some styling

We'd love to hear from you

If anything described in this article did not work for you or you have any other questions, add a comment to this article and we will try to help. You can also provide us with your website details and describe your issues via the enclosed contact form.

[gravityform id=”1″ title=”false” description=”false” ajax=”true”]

Work with us

Want results like this?

Book a free strategy call. We’ll look at where you stand on Google and in AI search — and tell you honestly whether we can help.

  • Founder-led — you speak with Dr Andrej Miklosik
  • Response within one business day
  • No obligation, no hard sell

Prefer to talk? 0432 055 562

Free strategy call

Tell us about your business

Your details stay with us. We don't share them or add you to a marketing list without asking.