Hi @laetitialu,
Unfortunately, I am unable to provide a customized solution that would help to change the structure of the breadcrumbs since I do not provide technical help for third-party plugins such as Yoast SEO.
I implemented breadcrumbs support as a bonus feature that is limited to the most basic scenarios.
If you would like to change the breadcrumbs trail you will need to adjust the below code snippet to your needs:
/**
* Insert the new breadcrumb after "Home"
*/
function pm_adjust_breadcrumbs($crumbs) {
global $post;
if(!empty($post) && $post->post_type == 'YOUR-CUSTOM-POST-TYPE') {
$new_crumbs = array(
array(
'Training area',
'https://example.com/training-area'
),
);
// Add the new breadcrumbs just after the first crumb ()"Home")
array_splice($crumbs, 1, 0, $new_crumbs);
}
return $crumbs;
}
add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 100);
If you are not certain how to use the custom code snippets please check out the below article:
https://permalinkmanager.pro/blog/how-to-add-php-snippet-to-wordpress-3-methods/#2-three-methods-to-use-wordpress-code-snippets
Best regards,
Maciej
-
This reply was modified 2 months ago by
Maciej Bis.
Thanks but sorry, it doesn’t work. Did i make a mistake?
‘domaine-de-formation’ is taxonomy.
Permalink : /domaine-de-formation/marketing-et-communication-digitale/
breadcrumb : accueil/marketing-et-communication-digitale/
My code :
/**
* Insert the new breadcrumb after "Home"
*/
function pm_adjust_breadcrumbs($crumbs) {
global $post;
if(!empty($post) && $post->post_type == 'domaine-de-formation') {
$new_crumbs = array(
array(
'Domaine de formation',
'https://exemple.com/domaine-de-formation'
),
);
// Add the new breadcrumbs just after the first crumb ()"Home")
array_splice($crumbs, 1, 0, $new_crumbs);
}
return $crumbs;
}
add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 100);
Please use the below code instead:
/**
* Insert the new breadcrumb after "Home"
*/
function pm_adjust_breadcrumbs($crumbs) {
if(is_tax('domaine-de-formation')) {
$new_crumbs = array(
array(
'text' => 'Domaine de formation',
'url' => 'https://example.com/test'
),
);
// Add the new breadcrumbs just after the first crumb ("Home")
array_splice($crumbs, 1, 0, $new_crumbs);
}
return $crumbs;
}
add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 1000);
Thanks you very much !! it’s work with ‘domaine_formation’ instead ‘domaine-de-formation’