WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Search Bar to search only products (3 posts)

  1. MyersMM
    Member
    Posted 4 months 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:

    http://bottomsandbeyondboutique.com/

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

  2. lorro
    Member
    Posted 4 months 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
    Member
    Posted 4 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic