-
Hey my breadcrumb links to my category page (like https://shivamk4.sg-host.com/category/seo/) but I want to link it to a separate WordPress page that has the same URL except the word Category in it (like https://shivamk4.sg-host.com/seo/), is there any way to solve this problem since i am creating a silo structure on my blog where one post is m=pillar page and other are supporting silos.
-
Hello,
Thanks for contacting us.
You can use the code given below to make changes to the breadcrumbs. Please ask your developer to use the below code and adjust it according to your needs:
/** * Allow changing or removing the Breadcrumb items * * @param array $crumbs The crumbs array. * @param Breadcrumbs $this Current breadcrumb object. */ add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { return $crumbs; }, 10, 2);Hope this helps. Let us know if you need any further assistance.
Hey, i am just a beginner blogger, i don’t have a developer. So, in case if you give me a simple solution which i can apply on my own.
Hello,
Thanks for getting back.
Please try the code given below:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { //Adding to single posts global $post; if(is_singular('post')){ //pass an array containing the name of the crumb, URL and //hide_in_schema option $catname = $crumbs[1][0]; $value[] = array( $catname, 'https://shivamk4.sg-host.com/seo/', 'hide_in_schema' => false ); //add this value as the second item in array array_splice( $crumbs, 1, 1, $value ); return $crumbs; } return $crumbs; }, 10, 2);Paste this in your functions.php file and let us know if it works for you or not.
We really look forward to your update.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
Thanks for getting back.
This was just an example to help you understand how the code will work. You will have to customize it according to the categories/subcategories that you use.
Please consider hiring a developer to modify the provided code as per your needs.
Let us know if you need any further assistance.
Hey, this is not working…
1. First, only SEO is linked to “https://shivamk4.sg-host.com/seo/” but in case if a post has a subcategory it is not redirected to the page.
check this screenshot for a better understanding
2. In case a page is under a different category like “Blogging” it still links to “https://shivamk4.sg-host.com/seo/”
I completely got your point Jaideep, but can you please modify the above PHP code for these two more categories:
https://shivamk4.sg-host.com/category/seo/keyword-research/ >>>> https://shivamk4.sg-host.com/seo/keyword-research/
and
https://shivamk4.sg-host.com/category/blogging/ >>>>> https://shivamk4.sg-host.com/blogging/
This will give me an idea of the pattern, so I can replicate the same for all of my categories and subcategory.
Hello,
Please use this code and let us know if it works for you or not
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { //Adding to single posts global $post; if(is_singular('post')){ //pass an array containing the name of the crumb, URL and //hide_in_schema option $catname = $crumbs[1][0]; $subcatname = $crumbs[2][0]; $value[] = array( $catname, 'https://shivamk4.sg-host.com/'.$catname, 'hide_in_schema' => false ); $newValue[] = array( $subcatname, 'https://shivamk4.sg-host.com/'.$catname.'/'.$subcatname, 'hide_in_schema' => false ); //add this value as the second item in array array_splice( $crumbs, 1, 1, $value ); array_splice( $crumbs, 2, 1, $newValue ); return $crumbs; } return $crumbs; }, 10, 2);We are looking forward to your update.
Wow it worked perfectly, but the one problem is still there in the subcategory “Keyword research” there is no separator sign (-) in URL that’s why it is sending to a 404 page.
It has not worked for me yet, as the separator sign in two word URL is missing that is why it is sending to a 404 page.
Hello,
Thanks for getting back.
I have fixed the code on your site. Please check and confirm.
Let us know if you need any further assistance.
Hello @William,
Thanks for contacting us.
I am glad that it worked for you.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you.
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.
The ticket ‘Breadcrumb navigation problem’ is closed to new replies.