Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26291

    Two questions here:

    1) I’d like to add a second search source to the search box available as a radio toggle (or some other selection means. Basically I want users to be able to use the default search you provide, or select a radio button to search an alternate source (listed in the form action) which is passed as a get via the terms entered. Ideally this would provide for adding a third source as well, so users just select the source of the search, enter their terms, and click the search icon to be routed to the appropriate results page. Is this possible and how?

    2) Searchform.php includes this comment:

    <?php

    // allows to add aditional form fields to modify the query (eg add an input with name "post_type" and value "page" to search for pages only)

    do_action('avia_frontend_search_form');

    ?>

    How, specifically would this be implemented at a code level for pages and posts respectively?

    #129954

    You can use the avia_frontend_search_form hook to add your custom form fields (eg with a child theme function, etc.) without modifying the searchform.php file itself. I.e. use the hook to call a function like:

    if(!function_exists('add_custom_avia_search_fields'))
    {
    add_action('avia_frontend_search_form', 'add_custom_avia_search_fields');
    function add_custom_avia_search_fields()
    {
    echo '<input type="hidden" id="post_type" name="post_type" value="my_post_type" />';
    }
    }

    – this function would add a hidden field to the search form which limits the search to the “my_post_type” post type.

    You can obviously build more complex forms (checkboxes, maybe with conditional logic and javascript code, etc.) but that’s beyond our support service and depending on your skills I’d suggest to hire a freelancer who can help you to build the form.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Search Sources and Search Facets’ is closed to new replies.