[Resolved] WordPress Search (GP and WooCommerce)

Home Forums Support WordPress Search (GP and WooCommerce)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1359725
    Vijay

    Hi Tom,
    I am creating a woocommerce site where I wish to be able to add a datalist of search terms. Any lightweight plugins that you would recommend? I want the visitor to be provided a suggestion of all words on the site (including product tags, categories). I am happy to build this list manually.

    I have seen this support article, however, the code below is not working for me.

    I need this to work in both the GP navigation search and default WordPress search box in footer. I am greatful for any help in this regards!

    add_filter( 'generate_navigation_search_output', 'vj_wc_navigation_search' );
    function vj_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="%2$s" list="product-categories-list" placeholder="Search for a Great Shot!">
    		</form>
    		<datalist id="product-categories-list">
    			<option>Architecture</option>
    			<option>Big Ben</option>
    			<option>Black & White</option>
    			<option>Brooklyn Bridge</option>
    			<option>Chrysler Building</option>  
    			<option>Cloud</option>
    			<option>Lake</option>
    		</datalist>',
    		esc_url( home_url( '/' ) ),
    		esc_attr( get_search_query() ),
    		esc_attr_x( 'Search...', 'label', 'generatepress' )
    	);
    }

    PS: i am lovin GenerateBlocks

    #1360240
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Is that function live on your website right now, or did you remove it?

    It looks like it should do the trick.

    Let me know 🙂

    #1362693
    Vijay

    All good Tom. It works now.

    #1363349
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.