Breadcrum don’t always work

#608106
  • Resolved Anonymous
    Rank Math free

    We took that Code from the Support Forum:

    /**
     * Filter to show all categories in breadcrumbs
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	$get_post_categories = get_the_category();
    	if ($get_post_categories) {
    	  foreach($get_post_categories as $cat) {
    		  $cat_list= [  $cat->name, get_category_link( $cat->term_id ) ];
    		  array_splice( $crumbs, 2, 0, array($cat_list) );
    	  }
    	}
    	return $crumbs;
    }, 10, 2);
    

    The Problem is that the Breadcrumbs showing up sometimes in correct order, and sometimes in wrong order.

    A post has parent Cat and Child Cat in the Breadcrumbs it shows up as chil cat – parent cat

Viewing 1 replies (of 1 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 share the affected URL/s so we can check the breadcrumbs placement as well?

    Meanwhile, please try this modified filter instead and let us know if the issue still persists:

    /**
     * Filter to show all categories in breadcrumbs
     */
    
     add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	$get_post_categories = get_the_category();
    	
    	if ($get_post_categories) {
    	  foreach($get_post_categories as $cat) {
    		if($cat->name!=$crumbs[0][0]){
    			$cat_list= [  $cat->name, get_category_link( $cat->term_id ) ];
    		  	array_splice( $crumbs, 1, 0, array($cat_list) );
    		}
    	  }
    	}
    	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 ‘Breadcrum don’t always work’ is closed to new replies.