CPT Taxonomy has no link in the breadcrumb

#88218
  • Resolved Saumya Majumder
    Rank Math free

    Hi,
    Let’s say I created a CPT named “Project” and now I’ve created a taxonomy for this CPT named “Project Category”. Now when the breadcrumb shows up on the site like:

    Home / Project Category / Some Project

    I can click on Home which will take me to the Home page but the “Project Category” is not clickable and shows up just as a text. Do you know how can I make it clickable to take users to the Project CPT archive page which they click on it?

Viewing 1 replies (of 1 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    This code added in your functions.php file should solve your issues, just remember to change the URL with the one you want.

    /**
     * This is an example to remove the second item in your post breadcrumbs
     * 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 ) {
            $hasProjectCategory = $crumbs[1][0] == "Project Category" ? true : false;
    
            if($hasProjectCategory == true){
               $modifiedCrumb = array(
    		"0"=>esc_html('Project Category'),
    		"1"=>esc_url('/project-category/'), // Modify this with the URL you want
    		"hide_in_scheme"=>false
    	    );  
                $crumbs[1] = $modifiedCrumb;
            }
    
    	return $crumbs;
    }, 10, 2);

    Looking forward to helping you. 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 ‘CPT Taxonomy has no link in the breadcrumb’ is closed to new replies.