Tutorials

How to add breadcrumbs in WordPress

Breadcrumbs are the little trail of links that shows where a page sits on your site, like “Home / Recipes / Baking / Sourdough bread”. They help visitors find their way back up to the section they came from, and they give search engines a clearer picture of how your site is organized.

For years, adding breadcrumbs to WordPress meant installing a plugin or editing your theme’s PHP files. Since WordPress 7.0, there’s a Breadcrumbs block built in. If you use a block theme, you can add breadcrumbs to your whole site from the Site Editor, without a plugin.

In this tutorial, we’ll add the Breadcrumbs block to your templates, go through its settings and what the trail shows on different pages, and then use a little code to choose which category a post shows. At the end, there’s a section on breadcrumbs and SEO, and what to do if you use a classic theme.

Add the Breadcrumbs block to your templates

The Breadcrumbs block works out the trail on its own, based on the page it’s shown on. That means you only need to add it once to each template, and it shows the right trail on every post and page that uses that template.

  1. Go to “Appearance” → “Editor” → “Templates”.
  2. Open the “Single Posts” template.
  3. Click the block you want the breadcrumbs to appear above, like the post title or the featured image.
  4. Click the “+” in the top toolbar, search for “Breadcrumbs” and add the block. You can also type “/breadcrumbs” on an empty line.
  5. Click “Save”.

Repeat this for the other templates you want breadcrumbs on, like “Pages” and “All Archives”. If you want breadcrumbs on every page of your site, add the block to your header template part instead, under “Patterns” → “Header”. The block hides itself on your front page by default, so you won’t end up with a lonely “Home” at the top of your home page. Depending on how your theme’s header is designed, it can look out of place there, so check it on a few pages before you save. If your header is sticky, the breadcrumbs then follow along as visitors scroll.

You can also add the block to a single post or page in the post editor, if you only want breadcrumbs in one place.

The settings

Select the block to see its settings in the sidebar:

  • Show home breadcrumb: the link to your home page at the start of the trail. On by default.
  • Show current breadcrumb: the title of the current page at the end of the trail. It’s not a link, since you’re already there. On by default.
  • Separator: the character between each item. It’s a slash by default, and you can replace it with anything you like, such as “›”, “→”, “•” or “|”.

Under “Styles”, you can change the colors, font, size, spacing and border, like on any other block. For a theme-wide change, set them in “Styles” → “Blocks & Elements” → “Breadcrumbs”, and every Breadcrumbs block on your site follows.

The “Advanced” panel has two more settings:

  • Show on homepage: shows the breadcrumbs on your front page as well, if the block is in a template or template part that’s used there.
  • Prefer taxonomy terms: for hierarchical post types that also have taxonomies, this builds the trail from the terms instead of the parent pages. You’ll only need it for custom post types. It does nothing for regular pages.

What the trail shows

The block builds a different trail depending on what kind of page it’s on:

  • Pages follow the page hierarchy, with each parent page in the trail: “Home / Services / Web design”.
  • Posts don’t have parents, so they use their category instead, including any parent categories: “Home / Recipes / Baking / Sourdough bread”. If your homepage is a static page and your posts are on a page of their own, set under “Settings” → “Reading”, that page is added after “Home”, like “Home / Blog / Recipes / Sourdough bread”.
  • Archives for categories, tags, authors and dates show their place in the same way. Custom post types get a link to their archive page.
  • Search results end with “Search results for: “…””, and the 404 page with “Page not found”.
  • Paginated pages get the page number at the end, like “Page 2”.

If a post has more than one category, the block picks one per level, and it uses the first one in alphabetical order. That isn’t always the one you’d choose, which is where the next section comes in.

Choose which category a post shows

There’s no setting for which category the trail uses, but there’s a filter for it: block_core_breadcrumbs_post_type_settings. You can use it to set a taxonomy for a post type, or a preferred term for each post.

If you use Yoast SEO, you can already mark one category as the primary category of a post, in the “Categories” panel of the post editor. This snippet makes the breadcrumbs use that category:

/**
* Use the Yoast SEO primary category in the Breadcrumbs block.
*
* @param array $settings Breadcrumbs settings for the post type.
* @param string $post_type The post type.
* @param int $post_id The post ID.
* @return array
*/
function my_breadcrumbs_primary_category( $settings, $post_type, $post_id ) {
if ( 'post' !== $post_type ) {
return $settings;
}
$primary = (int) get_post_meta( $post_id, '_yoast_wpseo_primary_category', true );
$term = $primary ? get_term( $primary, 'category' ) : null;
if ( $term && ! is_wp_error( $term ) ) {
$settings['taxonomy'] = 'category';
$settings['term'] = $term->slug;
}
return $settings;
}
add_filter( 'block_core_breadcrumbs_post_type_settings', 'my_breadcrumbs_primary_category', 10, 3 );

If a post has no primary category, or the one set has been removed, the block falls back to its first category.

Add the code to the functions.php file of a child theme, a code snippets plugin or a must-use plugin, so it isn’t lost when your theme updates.

Change the items in the trail

A second filter, block_core_breadcrumbs_items, runs just before the trail is shown. It gets the full list of items, each with a label and a url, and you can add, change or remove them. For example, this snippet replaces “Home” with the name of your site:

/**
* Show the site name instead of “Home” in the Breadcrumbs block.
*
* @param array $items Breadcrumb items, each with a label and a URL.
* @return array
*/
function my_breadcrumbs_home_label( $items ) {
if ( isset( $items[0]['url'] ) && trailingslashit( $items[0]['url'] ) === trailingslashit( home_url() ) ) {
$items[0]['label'] = get_bloginfo( 'name' );
}
return $items;
}
add_filter( 'block_core_breadcrumbs_items', 'my_breadcrumbs_home_label' );

Breadcrumbs and SEO

The Breadcrumbs block outputs a regular list of links in a nav element, labelled “Breadcrumbs” for screen readers, with the current page marked as such. It doesn’t add any structured data, though. That’s the BreadcrumbList markup Google can use to show the trail in its search results.

If you use Yoast SEO, you don’t need to do anything: it adds BreadcrumbList markup to every page, whether you use its own breadcrumbs or not. By default, though, Yoast’s trail for posts leaves the category out: it’s just “Home”, your posts page and the post. To add the category, go to “Yoast SEO” → “Settings” → “Advanced” → “Breadcrumbs”, and under “Breadcrumbs for post types”, set “Posts” to “Categories”. Yoast then uses the primary category, so with the snippet above, the trail your visitors see and the one in the markup match. With another SEO plugin, check its settings, since some only add the markup when you also use their breadcrumbs.

It’s also worth knowing that Google stopped showing breadcrumbs in mobile search results in January 2025, and only shows the domain there now. On desktop, the trail still appears. So the main reason to add breadcrumbs today is your visitors, not your search snippet.

If you use a classic theme

Classic themes don’t have the Site Editor, so there’s no template to add the block to. You can still add the Breadcrumbs block to individual posts and pages, but for breadcrumbs across the whole site, check whether your theme has its own breadcrumbs setting, or use the breadcrumbs feature in your SEO plugin.

Published December 3, 2026