- This topic has 12 replies, 3 voices, and was last updated 4 years, 6 months ago by
Tom.
-
AuthorPosts
-
November 29, 2018 at 9:41 am #743976
Arthur
I’ve created a Hook Element to add WooCommerce Breadcrumbs to the Entire Site. The Hook is for Content > inside_container. I’ve noticed that the Breadcrumbs do NOT appear on the Base Shop page (which is also the Front Page) and the Product Search page.
How can we have the Breadcrumbs appear on both page templates even though the Display Rules are set to Entire Site?
November 29, 2018 at 9:48 am #743981David
StaffCustomer SupportHi there,
why not just use the breadcrumbs that are added by the Theme? If you have the Woocommerce module activated you can activate them in Customizer > Layout > Woocommerce > General
November 29, 2018 at 9:53 am #743988Arthur
I want to change where the breadcrumbs display. The Theme adds the breadcrumbs within the Primary content area, but I want the breadcrumbs to display above the Primary AND Sidebar Areas.
November 29, 2018 at 10:00 am #743997David
StaffCustomer SupportOk, so you need to include the Front Page in your Display Rules.
I am not sure why it doesn’t work on the search results. Is the markup being output to searches and just missing the content?November 29, 2018 at 10:08 am #744003Arthur
The output is visible and the page has the same HTML structure as other Theme pages. I would show the site but it’s a member-only site.
I believe WooCommerce Search Results page uses a WooCommerce page template when the post_type parameter in the URL is product. I don’t really need to have the Breadcrumbs visible, but I would like to know if it is possible.
Here are sample URLs to show the different template pages based on the URL parameters:
Default Search Results template: https://www.yourdomain.com/?s=search_query
WooCommerce Search Results template: https://www.yourdomain.com/?s=search_query&post_type=productNovember 29, 2018 at 10:41 am #744031David
StaffCustomer SupportI just tried adding some basic HTML to the inside_container hook on Entire Site. And it outputs on the Product Search results. Give that a try and if it works for you then it could be related to the breadcrumb code.
November 29, 2018 at 11:28 am #744076Arthur
You’re right. HTML is injected on the Entire Site via that same Hook.
So the Breadcrumb code is being blocked (or suppressed) on the Front Page and Search Results template. Do you know how to override that?
November 29, 2018 at 11:38 am #744089David
StaffCustomer SupportCan you share the Breadcrumb code you have used?
November 29, 2018 at 11:45 am #744096Arthur
This is what I used:
<?php woocommerce_breadcrumb(array( 'delimiter' => '<span class="wcbc-delimiter"></span>' )); ?>
Thanks
November 29, 2018 at 12:34 pm #744134Arthur
@David I did some digging (and I’m not that fluent in PHP), but it looks like the woocommerce_breadcrumb function is an extension of the WC_Breadcrumb class that I assume only returns if the template is NOT the front_page or post_type_archive based on Line 77. You can view the file here: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Breadcrumb.html#7-354
I didn’t mention before, but I am using the following hook to change the output of the GP Navigation Search form:
add_filter( 'generate_navigation_search_output', 'tu_wc_navigation_search' ); function tu_wc_navigation_search() { printf( '<form method="get" class="search-form navigation-search" action="%1$s"> <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" /> <input type="hidden" name="post_type" value="product" /> </form>', esc_url( home_url( '/' ) ), esc_attr( get_search_query() ), esc_attr_x( 'Search', 'label', 'generatepress' ) ); }
The search results page displays the following body classes (which tells me this is a post_type_archive page):
archive search search-results post-type-archive post-type-archive-product
I’m not sure if this helps. Thanks again for your help.
November 29, 2018 at 5:43 pm #744322Tom
Lead DeveloperLead DeveloperThat looks to be the issue. It might be worth asking WooCommerce support if there’s a way for that function to work under those conditions. They might have a reason for not allowing it.
Let us know ๐
November 30, 2018 at 9:04 am #744832Arthur
WooCommerce support mentioned that they disable breadcrumbs for Search Results and Front Page since it is a “starting point” for the user. I could understand for the Front Page, but it looks as if their code does allow for a Search Result output. I’ll have to see how we can override that.
I will try to post a solution if I figure it out.
Thanks for your help!
November 30, 2018 at 10:33 am #744900Tom
Lead DeveloperLead DeveloperNo problem! ๐
-
AuthorPosts
- You must be logged in to reply to this topic.