Hello,
Thanks for contacting us, and sorry for any inconvenience that might have been caused due to that.
You can add this bit of code in functions.php
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$categories = array_map( function ( $category ) {
return $category->slug;
}, get_the_category() );
if ( in_array( 'category-slug', $categories ) ) {
$crumbs[1][1] = 'your-url'; // Add the desired URL
}
return $crumbs;
}, 10, 2);
Let us know how it goes. Looking forward to helping you.
Thank you.
Hey Sandeeepan, I’ve added the code to the bottom of the functions.php file in my theme editor and also swapped the ‘your-url’ for ‘https://thaifreu.de/chiang-mai/’, is this correct?
Either way, it appears that the breadcrums still function the same as before, where they link to the category, instead of the /chiang-mai/ page.
I’ll share a screenshot via sensitive data how the functions.php looks, perhaps I made a mistake in implementing it.
Thank you in advance for you time!
Hello,
Please enter the correct category-slug
in the code.
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$categories = array_map( function ( $category ) {
return $category->slug;
}, get_the_category() );
if ( in_array( 'category-slug', $categories ) ) { // change category slug to the correct slug
$crumbs[1][1] = 'your-url'; // Add the desired URL
}
return $crumbs;
}, 10, 2);
Hope this helps
Thank you
Ah wonderful, thank you Sandeepan, this worked! So if I later have more pages that I would like to replace the categories with, I’ll just repeat the procedure and add the filter for each of them, correct?
Hello,
In that case, you can repeat the line inside the function and just update the category-slug and the desired URL like the sample below and so on:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$categories = array_map( function ( $category ) {
return $category->slug;
}, get_the_category() );
if ( in_array( 'category-slug', $categories ) ) { // change category slug to the correct slug
$crumbs[1][1] = 'your-url'; // Add the desired URL
}
if ( in_array( 'new-category-slug', $categories ) ) { // change category slug to the correct slug
$crumbs[1][1] = 'new-url'; // Add the desired URL
}
return $crumbs;
}, 10, 2);
Hope that helps.
Thank you.
Wonderful, thank you so much Reinelle!
Hello,
You’re welcome.
We are super happy that we have addressed your concern. If you have any other questions in the future, know that we are here to help you.
If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.