skip to Main Content

I am trying to remove the (woo commerce)SHOP link from AIOSEO breadcrumbs. I have custom category pages so it is vital to remove the link. I can find filters for YOAST and Woo Commerce but am unable to find help with AIOSEO breadcrumbs.

I added this filter to function.php, but it had no effect.

add_filter( 'aioseo_breadcrumbs_trail', 'aioseo_breadcrumbs_trail' );
function aioseo_breadcrumbs_trail( $crumbs ) {
    foreach ( $crumbs as $key => $crumb ) {
        if ( is_a( $crumb['reference'], 'WP_Term' ) && 'Shop' === $crumb['reference']->slug ) {
            unset( $crumbs[ $key ] );
        }
    }
    return $crumbs;
}

2

Answers


  1. Chosen as BEST ANSWER

    Thanks so much, but it didn't remove the shop link.


  2. Here is my opinion:

    add_filter( 'aioseo_breadcrumbs', 'remove_shop_from_breadcrumbs' );
    
    function remove_shop_from_breadcrumbs( $crumbs ) {
        foreach ( $crumbs as $key => $crumb ) {
            if ( isset( $crumb['reference'] ) && is_a( $crumb['reference'], 'WP_Term' ) && 'shop' === $crumb['reference']->slug ) {
                unset( $crumbs[ $key ] );
            }
        }
    
        // Reindex array to prevent issues with missing keys
        return array_values( $crumbs );
    }
    

    Thank you!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search