Customizing Breadcrumbs for custom post types

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Could you please head over to Rank Math > Titles & Meta > [CPT] and ensure that the category is already selected in Primary Taxonomy?

    Taxonomy

    Once done, select the Team or Our Team as your primary taxonomy. Here’s a link for more information:
    https://rankmath.com/kb/how-to-choose-a-primary-category/

    I hope that helps.

    Thank you.

    Thank you Reineele but Team is now a category.

    Team is a page.

    So About is a page, Team is a page, and then Bios are an individual post type.

    Prabhat
    Rank Math agency

    Hello,

    In that case, you will have to modify and use this filter to customize the breadcrumbs as per the requirement: https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-breadcrumb-items

    Hope this helps.

    Thank you.

    We got it figured out.

    /**
     * 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 ) {
            //Adding to Bios Team Member Page
    	if(is_singular('bio')){
    		//pass an array containing the name of the crumb, URL and 
    		//hide_in_schema option	
    		$value[] = array(
    			'About', 
    			'/about/', 
    			'hide_in_schema' => false
    		);
    		
    		//add this value as the second item in array
    		array_splice( $crumbs, 1, 0, $value ); 
    		//pass an array containing the name of the crumb, URL and 
    		//hide_in_schema option	
    		$value1[] = array(
    			'Team', 
    			'/about/team/', 
    			'hide_in_schema' => false
    		);
    		//add this value as the third item in array
    		array_splice( $crumbs, 2, 0, $value1 );
    		$last = array_pop($crumbs);
    		$second_last = array_pop($crumbs);
    		array_push($crumbs, $last);
    		return $crumbs; 
    	}
    	return $crumbs;
    }, 10, 2);
    Prabhat
    Rank Math agency

    Hello,

    We’re glad that you got that sorted.

    Please feel free to get in touch if you require any further assistance.

    Thank you.

    Curtis,

    You are the man. This is just what I needed, exactly for Team 😀
    Last four rows are not needed ($last…return) but works great.

    Thank you,
    Peter

    Hello,

    @Patkó Glad that helped you.

    If you have any other concerns, please don’t hesitate to contact us anytime to assist you further.

    Looking forward to helping you.

    Thank you.

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

The ticket ‘Customizing Breadcrumbs for custom post types’ is closed to new replies.