Hello,
Thank you for contacting us and I am very happy to assist you.
From what I understand, you need to have a parent category and a child category in Breadcrumbs. Please correct me if I’m wrong.
But if that is what you are after then you need to customize your breadcrumbs in the front end adding the child category using the following filter:
/**
* Filter to change the primary term output of the breadcrumbs class.
*
* @param WP_Term $term Primary term.
* @param array $terms Terms attached to the current post.
*/
add_filter( 'rank_math/frontend/breadcrumb/main_term', function( $current_term, $terms ) {
return $current_term;
And please make sure this is enabled on your Breadcrumbs:
I hope that helps and please do not hesitate to contact us back anytime if you require further assistance.
Happy to help!
Cheers,
where should I add this code?
Hello,
Thanks for getting back to us.
I wasn’t able to mention where to add the code. My apologies.
Please add the given code to your themes functions.php file.
Please give it a try and let us know how it goes so we can assist you further.
Cheers,
Is the code correct? I am facing error:
“Your PHP code changes were rolled back due to an error on line 43 of file wp-content/themes/kadence/functions.php. Please fix and try saving again.”
I pasted this code”
/**
* Filter to change the primary term output of the breadcrumbs class.
*
* @param WP_Term $term Primary term.
* @param array $terms Terms attached to the current post.
*/
add_filter( ‘rank_math/frontend/breadcrumb/main_term’, function( $current_term, $terms ) {
return $current_term; (this is line 43)
Hello,
Thank you for the update, and apologies for the delay.
The filter needs to be customized based on your site’s structure, and it seems that the code is incorrect. Here’s the correct filter:
https://rankmath.com/kb/filters-hooks-api-developer/#5-filter-to-change-the-primary-term-output-of-the-breadcrumbs-class
However, the child category will only show in the breadcrumbs if it’s set up as the Primary Category for that specific product.
Please also ensure that you are using the categories as your primary taxonomy in Rank Math > Titles & Meta > Products
I hope that helps.
Thank you, and please don’t hesitate to contact us anytime if you need further assistance with anything else.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.