Fix Yoast SEO Breadcrumbs Not Showing Custom Post Type in the Hierarchy of Links

Here’s how to deal with the missing custom post type in the structure of links displayed by Yoast’s breadcrumb widget.

Yoast SEO is one of the many SEO plugins that can be installed on a WordPress website to help manage some of the technical parts of on-page optimization and the ability to deploy breadcrumbs is just one of the many things it can help you do.

What are breadcrumbs and why enable it?

Breadcrumbs enhances user navigation by providing a clear, hierarchical path of where the user is within the site structure. This not only improves the user experience by making it easier to backtrack to previous sections but also boosts SEO by creating additional internal links that help search engines understand the site’s structure and hierarchy.

The problem

Like many other plugins, Yoast SEO is bound to your existing website configuration. If parts of your website settings don’t satisfy what the plugin requires to do its function, it leads to some head-scratching scenarios like the missing details in the breadcrumbs trail I have encountered.

Basically, I have created a custom post type called “tools” using WP Engine’s ACF plugin. And then, I created my first tool called “Search Intent” accessible at https://regie.onehttps://regie.one/tool/search-intent-tool/.

If you notice the URL structure, it incorporates the singular form of my custom post type’s slug (tool). However, when I go on setup the display of Yoast’s breadcrumb widget, it didn’t follow the same structure. See below:

My expectation was for it to display: Home >> Tools >> Search Intent Tool. But look at what I got. Annoying right?

So what have I done to fix it? Well, it turns out there’s one (1) particular custom post type setting I leave off during the setup which lead me to a confusing scenario and that’s the ‘archive slug’.

The archive slug, if you’re using the mentioned ACF plugin, is buried under the ‘advanced settings’ -> ‘URLs’ section in custom post type edit window. See below:

Just enable the ‘achieve’ option and then the ‘archive slug’ field will appear below it where you could define the achieve slug of your custom post type.

Save the changes and just like that Yoast’s breadcrumbs widget realigns itself to display the ‘tools’ post type as part of structure. See below:

Now that is neat. Displaying ‘tools’ as part of the structure the way I wanted. (Of course, this is my first tool and I still need to fix my tools archive template.)

Too complicated, not able to follow

Here’s the step by step guide, but this is assuming you’re also using the ACF plugin by WP Engine like I am.

  1. Navigate to all custom post types

    Hover on ACF from the sidebar menu and click on ‘Post Types’ from the popup menu.

  2. Edit your custom post type

    From the list of post types, select (click) the one you want to set an archive slug for.

  3. Access archive settings

    Scroll down in the ‘edit post type’ window to see ‘advanced settings’ section. Click on it if not already expanded. Navigate to ‘URLs’ tab. Enable ‘archive’ option, then input the slug you want in the ‘archive slug’ field below it.

  4. Save changes

    Be sure to click on ‘save changes’ button to update your custom post type.

  5. Verify

    Visit one of the published items in your custom post type to check if the Yoast breadcrumb widget already recognized archive slug. If not, try clearing your website’s cache and repeat this step.

But I manually defined my custom post type

Understandable. We all like to avoid using plugins as much as possible.

The thing to look for in your manual custom post type definition is the option called ‘has_archive’. And all you have to do is give it the value of the slug you prefer for the archive of your custom post type. See sample code below for definition placement:

function create_tools_cpt() {
    $labels = array(
        //your CPT labels
    );
    $args = array(
        'label' => __('Tool', 'textdomain'),
        'description' => __('A custom post type for tools', 'textdomain'),
        'labels' => $labels,
        'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions', 'custom-fields'),
        'taxonomies' => array('category', 'post_tag'),
        'hierarchical' => false,
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'show_in_admin_bar' => true,
        'show_in_nav_menus' => true,
        'can_export' => true,
        'has_archive' => 'tools', // Custom slug for the archive page
        'exclude_from_search' => false,
        'publicly_queryable' => true,
        'capability_type' => 'post',
        'show_in_rest' => true,
    );
    register_post_type('tools', $args);
}
add_action('init', 'create_tools_cpt', 0);

There you have it!

I hope you fixed this particular Yoast breadcrumb issue on your website like I did.

Published:

Category:

,

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *