Skip to content

Instantly share code, notes, and snippets.

Last active July 18, 2023 01:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Snippet to Edit a breadcrumb path inside Yoast SEO
add_filter( 'wpseo_breadcrumb_links', 'fix_care_plan_bc_path' );
* Custom breadcrumb paths using Yoast SEO to fix care plan breadcrumb paths.
* @param [array] $links default param.
* @return [array] $links edited links path.
function fix_care_plan_bc_path( $links ) {
global $post;
if ( is_singular( 'cpplugins' ) || is_post_type_archive( 'cpplugins' ) ) {
$breadcrumb[] = array(
'url' => get_permalink( 25105 ),
'text' => 'Care Plans',
array_splice( $links, 1, -2, $breadcrumb );
return $links;
Copy link

You can see details on how this snippet works to make a custom yoast breadcrumb path on my blog.

Copy link

Thanks for providing this! I'm a novice at PHP, so this may seem like a ridiculous question. But if you can help, I would appreciate it:
What would I need to do to this code to add more than one link in the breadcrumb path? For example, you currently have it so it would appear: Home>Care Plans>Post
What if I needed it to be something like: Home>Additional Page>Care Plans>Post

Copy link

Just add another one into the breadcrumbs[] array.

Did you read over the article? It explains what the array is along with a video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment