Extending the functionality of Yoast breadcrumbs

I use Custom Post Types in basically every site I make. I also use the Yoast SEO plugin on almost every site I make. I also try and use Yoast SEO Breadcrumbs on every site.

Yoast isn’t a perfect solution though and their breadcumbs are about as basic as it gets. Which is great for regular blogs or sites with normal / logical urls…unfortunately not every site is going to work like this.

Often, I will need to change the url of a post type so that it has a standard page for the parent of the post types. This requires a few steps.

First, make sure to setup the correct rewrites for your CPT like so:

This will now change your default CPT url structure. Which is awesome, but the Yoast breadcrumbs do not take this into account (and why would it?). So we need to hook into one of the Breadcrumbs filters and edit it’s link structure. Like so:

This will now follow your custom link structure up to your highest parent page.

A big thanks to Steve Taylor for the majority of this code.