Saturday, July 20, 2024
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 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( ‘/’ ); ?>”>
<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’ ) ?>” />
<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” />

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.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, 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.