- This topic has 10 replies, 3 voices, and was last updated 2 years, 6 months ago by David.
-
AuthorPosts
-
February 26, 2019 at 12:16 pm #822560Neil
Hi,
On my Woocommerce product page I’m showing the breadcrumb above my product title. The breadcrumb includes the product title, which means that it is showing the product title twice, right next to one another.
Is there a way to remove the product title from the breadcrumb?
Thanks,
Neil.
February 26, 2019 at 4:35 pm #822719LeoStaffCustomer SupportHi there,
The breadcrumb feature is actually coming from WooCommerce itself and GP doesn’t have control over it.
I found this article on their documentation that might help:
https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/If not then please check with their support.
Let me know if this helps ๐
February 27, 2019 at 2:27 am #823015NeilThanks Leo, all sorted now.
If anyone else is looking to do the same, a really simple bit of code.
add_filter( 'woocommerce_get_breadcrumb', 'ed_change_breadcrumb' ); function ed_change_breadcrumb( $breadcrumb ) { if(is_singular()){ array_pop($breadcrumb); } return $breadcrumb; }
February 27, 2019 at 8:08 am #823485LeoStaffCustomer SupportAwesome!
Thanks for reporting back ๐
November 2, 2020 at 10:51 pm #1515606roadlinkHi,
This code removes product title but also removes link from category.
just fyi.September 7, 2021 at 11:38 pm #1922515AlfonsoIs possible to remove product title without remove link from category??
Thanks
September 8, 2021 at 3:16 am #1922707DavidStaffCustomer SupportHi there,
simplest method would be with some CSS. But if you want to remove the breadcrumb title entirely on the single post, then the PHP Snippet 2 referenced here can be used:
https://www.businessbloomer.com/woocommerce-rename-a-breadcrumb-item/
That code can be edited to replace the last crumb will null:
add_filter( 'woocommerce_get_breadcrumb', 'bbloomer_single_product_edit_prod_name_breadcrumbs', 9999, 2 ); function bbloomer_single_product_edit_prod_name_breadcrumbs( $crumbs, $breadcrumb ) { if ( is_product() ) { global $product; $index = count( $crumbs ) - 1; // product name is always last item $value = $crumbs[$index]; $crumbs[$index][0] = null; } return $crumbs; }
then of course you have the Separators to deal with.
And Woo Provides this PHP Snippet to change them:https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/#section-2
Which you can modify to also return null:
add_filter( 'woocommerce_breadcrumb_defaults', 'wcc_change_breadcrumb_delimiter' ); function wcc_change_breadcrumb_delimiter( $defaults ) { // Change the breadcrumb delimeter from '/' to null $defaults['delimiter'] = null; return $defaults; }
And then some CSS to add them back in after all crumbs except for the last one:
.woocommerce-breadcrumb a:not(:last-child):after { content: '/'; margin: 0 5px; }
September 8, 2021 at 4:39 am #1922790AlfonsoThanks, is possible to hide part of title, not entirely?
September 8, 2021 at 5:15 am #1922823DavidStaffCustomer SupportHow do you mean ‘part of title’ ?
September 8, 2021 at 6:09 am #1922862AlfonsoSeptember 8, 2021 at 8:45 am #1923178DavidStaffCustomer SupportYou can try this snipept:
add_filter( ‘woocommerce_get_breadcrumb’, ‘bbloomer_single_product_edit_prod_name_breadcrumbs’, 9999, 2 );
function bbloomer_single_product_edit_prod_name_breadcrumbs( $crumbs, $breadcrumb ) { if ( is_product() ) { global $product; $index = count( $crumbs ) - 1; // product name is always last item $value = $crumbs[$index]; $crumbs[$index][0] = substr($crumbs[$index][0], 0, 5); } return $crumbs; }
In this line,
$crumbs[$index][0] = substr($crumbs[$index][0], 0, 5);
the number 5 is the number of characters to display. Change that to suit.
-
AuthorPosts
- You must be logged in to reply to this topic.