• Hi,

    Is it possible to have multiple tailored search bars on a site?

    My use case is fairly simple, on the majority of my pages I’d like a standard search bar, which searches all content. But then on certain pages I would like a search bar which only searches for items in a particular category – and so that would also include what shows up in the autocomplete pop-up too.

    It’s something I usually do by passing a simple query along with my search term (so it ends up like ?s=search+term&cat=10&submit=), but unfortunately when I try that on the site I’m trialling SearchIQ on it doesn’t work in the same way.

    Many thanks for any advice you can offer.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author SearchIQ

    (@searchiq)

    Yes, SearchIQ can have multiple tailored search bars. Please use our search widget to display search results for the selected category/categories. Please check the screenshot for reference.
    https://prnt.sc/JHMzHiSVWXw1

    Is there a shortcode to accomplish this feature? We don’t use widgets.

    Plugin Support Rahul Arora

    (@rahularora86)

    We support shortcode like below which can be placed anywhere in the page/post content.

    [siq_searchbox type="search-bar" placeholder="Search here" post-types="post,product" width="500″ placement="left"]

    You can add the below code to your theme’s ‘functions.php’ file to convert the widget into the shortcode.

    function siq_search_widget_shortcode($atts) {
    ob_start();

    // Default widget instance values (you can override via shortcode attrs)
    $instance = shortcode_atts([
    'title' => '',
    'placeholder' => 'Search',
    'postTypes' => '',
    'postcatidfilter' => '',
    'postCatFilterClause' => ''
    ], $atts);

    // Convert comma-separated values to array where needed
    if (!empty($instance['postTypes'])) {
    $instance['postTypes'] = explode(',', $instance['postTypes']);
    }

    if (!empty($instance['postcatidfilter'])) {
    $instance['postcatidfilter'] = explode(',', $instance['postcatidfilter']);
    }

    // Render widget
    the_widget('SIQ_Search_Widget', $instance);

    return ob_get_clean();
    }
    add_shortcode('siq_search', 'siq_search_widget_shortcode');

    And can use it in one or combined ways below:

    Basic:
    [siq_search]

    With custom placeholder:
    [siq_search placeholder="Search products…"]

    With post types:
    [siq_search postTypes="post,page,product"]

    With category filter:
    [siq_search postcatidfilter="1,2,3"]

    Sea Jay

    (@jcollier)

    Thank you, Rahul.

    We added this shortcode to this page.

    [siq_searchbox type=”search-bar” placeholder=”Search glossary terms” post-types=”glossary”]

    https://www.603la.net/get-legal-aid/glossary/ password: 603la

    A search for “abrogate” yields no results, although there is a post in that custom post type for that term.

    https://www.603la.net/glossary/abrogate/

    Is there a syntax problem with our shortcode?

    -Jay

    Plugin Support Rahul Arora

    (@rahularora86)

    Hi, we have checked the indexed documents on your site and can see only the page https://www.603la.net/get-legal-aid/glossary/ is indexed.
    The page links on the Glossary page, like https://www.603la.net/glossary/abrogate/ or https://www.603la.net/glossary/accrual/, are not indexed. Please select the post type ‘glossary’ for indexing, Resynchronize posts from the plugin settings, and test if the page is displayed in the search results.

    Moreover, you are using post-types="glossary" in the shortcode. We need to use the below attribute in the shortcode to specify the post type.
    postTypes=”glossary”

    • This reply was modified 2 weeks, 2 days ago by Rahul Arora.
Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.