Breadcrumb: Add Custom Link for Multiple Custom Taxonomyies

#454431
  • Resolved Thomas
    Rank Math free

    I have a Custom Post Type (Product) with Custom Taxonomy

    I have two Custom Taxonomies for Product
    Brands
    Categories

    Current Rankmath Breadcrumbs
    Home | Brand Name
    Home | Category Name

    I like to do the following add a custom link based on the custom taxonomy
    Home | Brands (links to /custom-link/) | Brand Name
    Home | Categories (links to /custom-link/) | Category Name

    Output

    Home | Brands | Brand Name
    Home | Categories | Category Name

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    In this case, you can use and customize this filter to add the crumbs to your site:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-breadcrumb-items

    Here’s a filter you can customize to achieve that structure:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	$post_type = get_post_type(get_queried_object());
    	
    	if ($post_type == 'your_post_type') {
    		$crumbs[1][0] = 'Brands';
    		$crumbs[1][1] = 'https://yourdomain/CPT'; // Change this on the live website to match the correct URL
    		$crumbs[2][0] = get_the_title();
    	}
    
    	return $crumbs;
    }, 10, 2);

    The filter should be added to your active themeā€™s functions.php file. Hereā€™s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Let us know how this goes.

    Thank 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.

Viewing 1 replies (of 1 total)

The ticket ‘Breadcrumb: Add Custom Link for Multiple Custom Taxonomyies’ is closed to new replies.