How to remove custom category base from breadcrumb

#80891
  • Resolved Firsthatch
    Rank Math free

    Dear,

    I am trying to remove the custom category base from the breadcrumb with the following code. However, it cannot work. I cannot find the reason. Would it be possible to help me on this issue?

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(is_singular('application')){	
    		//Unset elements with key 1
    		unset($crumbs[2]);
                    $crumbs = array_values($crumbs);
    		return $crumbs; 
    	}
    	return $crumbs;
    }, 10, 2);
Viewing 8 replies - 1 through 8 (of 8 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.

    To be sure, the code comment says “remove key 1” but you are removing index 2, is it the one you want to remove?

    About this line:
    is_singular('application')

    Could you check if the custom post type has that name?

    If both of those “things” are fine, let us know and we will have to take a deeper look.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Firsthatch
    Rank Math free

    Hi Alberto,

    Thank you for the reply. I confirmed that both things are fine. Could you take a deeper look at it?

    Best regards,
    Lin

    Alberto
    Rank Math business

    Hello,

    Of course, to do that, please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Firsthatch
    Rank Math free

    Hello,

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

    Thank you.

    Firsthatch
    Rank Math free

    Hi Alberto,

    I have updated the sensitive data. Could you check it further?

    In addition, I add the code by Code Snippet. You can find a file called function.php in the dashboard of Code Snippet.

    Best regards,
    Lin

    Michael Davis
    Rank Math pro

    Hello,

    I added the following code to your snippets functions file which seems to have fixed your issue:

    
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(is_single() && get_post_type()=='application'){	
    		unset($crumbs[2]);
            $crumbs = array_values($crumbs);
    		return $crumbs; 
    	}
    	return $crumbs;
    }, 10, 2);
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    Firsthatch
    Rank Math free

    Thank you very much. It works well now.

    Michael Davis
    Rank Math pro

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me 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 do 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 8 replies - 1 through 8 (of 8 total)

The ticket ‘How to remove custom category base from breadcrumb’ is closed to new replies.