mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-01 11:52:25 +08:00
https://stackoverflow.com/questions/78918303/remove-woocommerce-shop-link-from-aioseo-breadcrumbs
12 lines
442 B
Text
12 lines
442 B
Text
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 );
|
|
}
|