Support » Plugin: Dave's WordPress Live Search » [Plugin: Dave's WordPress Live Search] restrict results to a custom post type

  • I’m having difficulty coming up with a way to get the live search to restrict results to a custom post type “product” and am hoping someone could help.

    I’m using a hidden field in the search form generated in a specific product template to set the post type as suggested else where in the forums e.g….
    <input type="hidden" name="post_type" value="product" />

    Which seems to work well for the form submit results (via Relevanssi) but not so for the live search popup results.

    Does anyone know how I can achieve this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Dave Ross


    The latest beta of version 3.0 should pass all your hidden parameters on to WP_Query. The 2.x versions just cared about language selection.

    3.0a1 and 3.0a2 don’t pass the hidden parameters. Can you post a version that does somewhere, or an example that works?

    I am actually looking for similar functionality, which I can’t seem to figure out how to do. I’ve managed to restrict the live search results to a single post_type by editing DavesWordPressLiveSearchResults.php line 69:
    $wpQueryParams['post_type'] = 'any';
    If you change ‘any’ to your desired post_type, it’ll work.

    My problem is with getting 2 post_types to work, for example ‘post’ AND ‘custom’, and I had no success with defining that properly (my knowledge in PHP is very limited). Would anyone be kind enough to provide a fix for this (even though it’s hard code and prone to get messed up with future updates)?


    Could you possible use an array to assign the values of the post types?

    I haven’t tested this though.

    To get only the products from woocommerce:
    $wpQueryParams[‘post_type’] = ‘products’;

    It worked pretty fine for us.

    using $wpQueryParams[‘post_type’] = ‘products’;
    didn’t give me any dropdown results. The loading circle popped up, but nothing came up for the live search. It only worked for me with $wpQueryParams[‘post_type’] = ‘any’;

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Dave's WordPress Live Search] restrict results to a custom post type’ is closed to new replies.