Reputation: 31
In my Storefront wordpress I'm using the woocommerce product tags to display my products in an alternative way. On the tag archive pages the breadcrumb says
Home > Products tagged “Example Tag” or rather Startseite > Produkte verschlagwortet mit „Example Tag“ since I have a German language site.
-> I want to get rid of the "Products tagged" ("Produkte verschlagwortet mit") and have the Example Tag (without the quotation marks) only displayed in the Breadcrumb:
Home > Example Tag ( Startseite > Example Tag)
I found a lot of stuff how to customize the breadcrumb in general, but nowhere how to red rid of that specific problem.
Any ideas?
Upvotes: 3
Views: 2072
Reputation: 1
This code works to removed Products tagged for English text Breadcrumb :
// Customize text strings
function my_gettext( $translation, $text, $domain ) {
switch ( $translation ) {
case 'Products tagged “%s”' :
$translation = __( '%s', 'woocommerce' );
break;
}
return $translation;
}
add_filter( 'gettext', 'my_gettext', 20, 3 );
But you can try this for French or other language than English :
///// Woocommerce : Remove "Products tagged" from product tags breadcrumbs FR
function my_gettext( $translation, $text, $domain ) {
if ( strpos( $text, 'Products tagged' ) !== false ) {
$translation = '%s';
}
return $translation;
}
add_filter( 'gettext', 'my_gettext', 100, 3 );
Upvotes: 0
Reputation: 509
I know it's been a while, but it may help someone else. I've come up with this:
/**
* Remove "Products tagged" from product tags breadcrumbs
*/
add_filter('woocommerce_get_breadcrumb', 'woocommerce_breadcrumbs_remove_text', 10);
function woocommerce_breadcrumbs_remove_text($crumbs) {
// Check if we are in a product tag archive page
if (is_product_tag()) {
// Point to the last element of the breadcrumbs array, specifically the breadcrumb we are going to edit
end($crumbs);
// Get the text to edit (array key number 0)
$last = $crumbs[key($crumbs)][0];
// Perform a regular expression to keep only what's between quotes (“ and ”)
$replace = preg_replace('/[\s\S]+\“([\s\S]+)\”/', '$1', $last);
// Register the new text to the breadcrumb array
$crumbs[key($crumbs)][0] = $replace;
// Reset the array pointer
reset($crumbs);
}
// Return the filtered breadcrumbs array
return $crumbs;
}
This is a filter using the woocommerce_get_breadcrumb
hook. You should put this code into your theme's functions.php file.
Upvotes: 4
Reputation: 692
Untested, but try this:
// Customize text strings
function my_gettext( $translation, $text, $domain ) {
switch ( $translation ) {
case 'Products tagged “%s”' :
$translation = __( '%s', 'woocommerce' );
break;
}
return $translation;
}
add_filter( 'gettext', 'my_gettext', 20, 3 );
If you're using a ThemeBlvd theme, do this instead:
// Customize "Products tagged" in breadcrumbs
function my_locals( $locals ) {
$locals['crumb_tag_products'] = '%s';
return $locals;
}
add_filter('themeblvd_frontend_locals', 'my_locals');
Upvotes: 1
Reputation: 218
You could select that item from Inspect Element and write custom CSS for it and set it to
display: none;
Upvotes: 0