Last active
July 18, 2023 01:34
-
-
Save mrkdevelopment/5df47150bc3d0905e463fe0fd94bcb9c to your computer and use it in GitHub Desktop.
Snippet to Edit a breadcrumb path inside Yoast SEO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just add another one into the breadcrumbs[] array.
Did you read over the article? It explains what the array is along with a video.