Search Bar to search only products (3 posts)

  1. MyersMM
    Posted 2 years ago #

    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:



  2. lorro
    Posted 2 years ago #

    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.

  3. MyersMM
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic