- This topic has 10 replies, 3 voices, and was last updated 1 year, 6 months ago by
David.
-
AuthorPosts
-
February 26, 2019 at 12:16 pm #822560
Neil
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.
GeneratePress 2.2.2GP Premium 1.7.8February 26, 2019 at 4:35 pm #822719Leo
StaffCustomer 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 ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 27, 2019 at 2:27 am #823015Neil
Thanks 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 #823485Leo
StaffCustomer SupportAwesome!
Thanks for reporting back ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 2, 2020 at 10:51 pm #1515606roadlink
Hi,
This code removes product title but also removes link from category.
just fyi.September 7, 2021 at 11:38 pm #1922515Alfonso
Is possible to remove product title without remove link from category??
Thanks
September 8, 2021 at 3:16 am #1922707David
StaffCustomer 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; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 8, 2021 at 4:39 am #1922790Alfonso
Thanks, is possible to hide part of title, not entirely?
September 8, 2021 at 5:15 am #1922823David
StaffCustomer SupportHow do you mean ‘part of title’ ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 8, 2021 at 6:09 am #1922862Alfonso
September 8, 2021 at 8:45 am #1923178David
StaffCustomer 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.