How to insert breadcrumbs into WordPress with Yoast

A breadcrumb gives information about  the category under which the current page is in a site.  So if the post we are reading is in the category Internet, we will see thanks to the breadcrumb an indication like  Home >> Internet >>Current article

Other types of breadcrumbs exist, as the ones related to the path a user followed to reach the current page, but here we will see the location breadcrumbs mentioned above,  managed by the  Yoast SEO plugin for WordPress.

This guide explains, indeed, how to insert the breadcrumbs on  WordPress using the Yoast SEO plugin.  Yoast SEO can work together with your theme by showing breadcrumbs for posts and pages. It is just needed to insert some PHP code into some files, but it is easy.

The examples show how to insert Yoast code into the template files of the Twenty Sixteen theme, but for other themes things should be similar.

How to activate Yoast Breadcrumbs

  1. Activate the advanced features: from Seo->Dashboard->Features, select enabled for the item Advanced settings pages.
  2. In the tab Seo->Advanced, go on Breadcrumbs settings and select Enabled for the item Enable breadcrumbs.
  3. If you want the category shown before the page, (like Home->category->page), select Category for the item Taxonomy to show in breadcrumbs for post types

How and where to insert the PHP code mentioned by Yoast

  1. Do a backup copy of the files /page.php and /single.php
  2. Open the template editor from Appearance->Editor
  3. If you want to insert the breadcrumbs into posts, open the file single.php and, as Yoast says here, insert the following code

    after the following lines
  4. Save clicking on Update file
  5. If you’d like to insert the breadcrumbs also for the pages, open page.php and insert the following lines (as before)

    after the following lines
  6. Save clicking on Update file

All done. You have your breadcrumbs on your posts and pages.
Remember that when the theme will be updated all the modifications will be lost. The correct way to keep the modifications is to create a child theme, but I don’t know how to do this yet.

Here is the result, directly from this site.

Breadcrumb with Yoast SEO
Breadcrumb before the title