How to remove base of woocommerce from breadcrumbs

#36619
  • Resolved Firsthatch
    Rank Math free

    Dear

    I used RankMath to remove base of woocommerce from URL. It works well. However, I found the base is still shown in breadcrumbs. Is it possible to remove it from breadcrumbs?

    Look forward to your reply.

    Best regards,
    Lin

    • This topic was modified 4 years, 1 month ago by Firsthatch.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello,

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

    It does not look like your store is using WooCommerce, is this correct?
    I have tested single products on my end but the “products” crumb item is never added by default.
    If you have a custom products post type, then you will need to come up with some custom code to remove this item using the following filter:

    /**
     * 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 ) {
    	return $crumbs;
    }, 10, 2);

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hi,

    I am using Elementor Pro to customize the page so that it does not look like Woocommerce.

    In addition, I added the code to function.php directly. However, it cannot work. Should I change anything in the code you gave me?

    Look forward to your reply.

    Best regards,
    Lin

    Hi there,

    Thanks for the reply.

    The code will need to be customized further to work as expected.
    Here is some sample code to remove the second item from the 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 ) {
    	if(is_product() && isset($crumbs[1])){
    		unset($crumbs[1]);
    		$crumbs = array_values($crumbs);
    		return $crumbs;
    	}
    	return $crumbs;
    }, 10, 2);
    

    I hope this info helps. Thank you.

    Hi,

    Thank you for the reply.
    It still cannot work. I am not sure what should I add or change in this code.

    Hello,

    Thank you for getting back to us.

    We might need to take a closer look at the settings. 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.

    Hello,

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

    Thank you.

    Hi

    I have already added the info. Please check it.
    In addition, I am using code snippet to add the code into function.php. You can also use it if needed.

    Hello,

    Thank you for contacting Rank Math today.

    The code works when added to your functions.php file.

    Could you please check?

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hi

    I found that “Products” is removed from single product page. However, it is still shown in the product category archive as the link below. Is it possible to remove?

    https://woocommerce-338624-1101501.cloudwaysapps.com/shock-indicator/

    I moved the code to Code Snippet. It works well. I did not use child theme now, so the code in function.php may disappear.

    In addition, I found an issue in following page.
    Only this link show “product-category” in URL. The content in the URL is wrong. It is not product archive content but the single product content.

    https://woocommerce-338624-1101501.cloudwaysapps.com/product-category/pallet-cushion/

    Hi there,

    Thanks for the follow up.

    I have modified the code to the following :

    /**
     * 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 ) {
    	if(is_product() || is_product_category()){
    		unset($crumbs[1]);
    		$crumbs = array_values($crumbs);
    		return $crumbs;
    	}
    	return $crumbs;
    }, 10, 2);

    Regarding the second problem, this link is affected because the product shares the same name as one of your product categories “Pallet Cushion”. You will need to either change the name of the category or the product to fix this.

    I hope this info helps 🙂

    Hi

    Thank you very much. It works pretty well now.

    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 13 replies - 1 through 13 (of 13 total)

The ticket ‘How to remove base of woocommerce from breadcrumbs’ is closed to new replies.