Home Wordpress Tricks Change default WordPress search to search for woocommerce products

Change default WordPress search to search for woocommerce products

by therichpost
1 comment
How to add custom meta title and meta description in Wordpress?

Hello, welcome to therichpost.com. In this post, I will tell you How to Change default WordPress search to search for woocommerce products? WordPress is the best cms. There is default wordpress search form but we can it for search Woocommerce products also with simple trick.

This is the main code for search woocommerce products:

<input type=”hidden” value=”product” name=”post_type” id=”post_type” />

Here is the working form and you can replace this form with default wordpress form:

<form role=”search” method=”get” class=”search-form” action=”<?php echo home_url( ‘/’ ); ?>”>
<label>
<span class=”screen-reader-text”><?php echo _x( ‘Search for:’, ‘label’ ) ?></span>
<input type=”search” class=”search-field” placeholder=”<?php echo esc_attr_x( ‘Search …’, ‘placeholder’ ) ?>” value=”<?php echo get_search_query() ?>” name=”s” title=”<?php echo esc_attr_x( ‘Search for:’, ‘label’ ) ?>” />
</label>
<input type=”submit” class=”search-submit” value=”<?php echo esc_attr_x( ‘Search’, ‘submit button’ ) ?>” />
<input type=”hidden” value=”product” name=”post_type” id=”post_type” />
</form>

There are so many tricks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

You may also like

1 comment

alexa December 28, 2017 - 10:18 am

chrome://settings/passwords

Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.