Categories

Saturday, November 23, 2024
#919814419350 therichposts@gmail.com
Wordpress Tricks

Change default WordPress search to search for woocommerce products

How to add custom meta title and meta description in Wordpress?

Change default WordPress search to search for woocommerce products

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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

1 Comment

Leave a Reply

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