Wednesday, June 12, 2024
WoocommerceWordpress Tricks

Woocommerce Custom Search With Select Query

How to add download pdf link in woocommerce single product page?

Woocommerce Custom Search With Select Query - The Rich Post

Hello to all, welcome to In this post, I will tell you, Woocommerce Custom Search  With Select Query.

WordPress is the best CMS and Woocommerce is the best Ecommerce Plugin.

Woocommerce Custom Search  With Select Query, this is very basic thing but sometime, it is difficult to develop easy things so I am sharing this code on my blog.


Here is the working and tested code and you can this into your any wordpress theme’s template file:


<form method="get" id="productS">
<input type="text" name="searchtxt" class="" />
<button type="search"><i class="icon-search searcBtn"></i></button>
    global $wpdb;
    $result = $wpdb->get_results("SELECT * FROM `wp_posts` WHERE `post_title` like '%".$_GET['searchtxt']
    ."%' and post_type = 'product'");
    foreach ($result as $product) {
      $_product = wc_get_product( $product->ID );

      $attachment_ids[0] = get_post_thumbnail_id($product->ID);
      $attachment = wp_get_attachment_image_src($attachment_ids[0], 'thumbnail' );
      <li><img src="<?php echo $attachment[0] ?>" /></li>
      <li><?php echo $product->post_title ?></li>  
<script src=""></script>
<script type="text/javascript">
  jQuery(document).ready(function($) {
    $(".searcBtn").click(function(event) {

If you have any query related to this post, then do comment below or ask questions.

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.

Leave a Reply

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