[Resolved] Hook Element Not Working for WooCommerce Product Search Page

Home Forums Support [Resolved] Hook Element Not Working for WooCommerce Product Search Page

Home Forums Support Hook Element Not Working for WooCommerce Product Search Page

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • #743976

    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?

    Customer Support

    Hi 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



    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.

    Customer Support

    Ok, 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?


    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=product

    Customer Support

    I 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.


    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?

    Customer Support

    Can you share the Breadcrumb code you have used?


    This is what I used:

    <?php woocommerce_breadcrumb(array(
    	'delimiter' => '<span class="wcbc-delimiter"></span>'
    )); ?>



    @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() {
    		'<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" />
    		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.

    Lead Developer
    Lead Developer

    That 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 ๐Ÿ™‚


    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!

    Lead Developer
    Lead Developer

    No problem! ๐Ÿ™‚

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.