How to change breadcrumb category URL?

#436433
  • Resolved DarkMoonGuardian
    Rank Math free

    Hello!

    I have activated the breadcrumbs on my website and they have been created with the following structure

    Home / Category / Post

    Which would be perfect if I didn’t want to remove the slug “/category/”.

    In my case it is not possible to go to “General settings / Links / Remove category base” because with SEO strategy I use a page as a category as I am adding content to it.

    So I ask if it is possible for the breadcrumb to remove the /category/ from the link.

    Example links:

    The “dead” URL as a category that I don’t use – https://psicorevista.com/category/duelo/
    The effective URL as a category – https://psicorevista.com/duelo/
    The URL of a post within the category – https://psicorevista.com/duelo/duelo-infantil/

    So I want the breadcrumb URLs to look like this:
    psicorevista.com | psicorevista.com/duelo/ | psicorevista.com/duelo/duelo-infantil/

    and NOT like this:
    psicorevista.com | psicorevista.com/category/duelo/ | psicorevista.com/duelo/duelo-infantil/

    Is it possible to make a change to remove the /category/ from the breadcrumb?
    I hope I have explained myself correctly

    Thank you very much in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.

    Please use the following filter to remove the category base from the breadcrumb URLs:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(strpos($crumbs[1][1], 'category/')) {
    		$crumbs[1][1] = str_replace('category/', '', $crumbs[1][1]);
    		return $crumbs;
    	}
    	return $crumbs;
    }, 10, 2);

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope this helps. Let us know if you need any other assistance.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for your patience.

    Your account name is already updated upon checking..

    If you wanted to use a different username, please share it in the sensitive data section so we can check the availability and update it for you.

    Looking forward to helping you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    We have changed your username as requested and the URL of your user profile is also updated.

    Please check and let us know if you need any other assistance.

    Thanks.

    Thank you very much!

    It worked!

    Hello,

    We are super happy that we have addressed your concerns. 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.

Viewing 7 replies - 1 through 7 (of 7 total)

The ticket ‘How to change breadcrumb category URL?’ is closed to new replies.