WordPress.org

Support

Support » Plugins and Hacks » Search Bar to search only products

Search Bar to search only products

  • I have the following code for my search bar:

    <div id="search-bar">
    				<form method="get" id="searchform1" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    					<input type="text" value="<?php esc_attr_e('search this site...','eStore'); ?>" name="s" id="searchinput" />
    
    					<input type="image" src="<?php echo get_template_directory_uri(); ?>/images/search-icon.png" id="searchsubmit" />
    				</form><!– end searchform–>
    			</div> <!-- #search-bar -->

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I need to alter it so the search bar only comes back with products, not any of the articles written… Any ideas? The url is:

    http://bottomsandbeyondboutique.com/

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • An idea, but I’ve not tried it …
    <input type="hidden" name="post_type" value="product" />
    May not pick up instances of post_type=product_variation though.

    I put that in addition to the above code and when I search for “diapers” it brings up nothing… Not sure why at the moment.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search Bar to search only products’ is closed to new replies.