Support » Plugin: Relevanssi - A Better Search » [Plugin: Relevanssi – A Better Search] Dropdown category search: How to set default category?

  • Thanks for this awesome plugin. It’s exactly what I was looking for and more!

    I’m using this code from the FAQ to implement a dropdown search:

    <form method="get" action="<?php bloginfo('url'); ?>">
        <div><label class="screen-reader-text" for="s">Search</label>
        <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <?php
        wp_dropdown_categories(array('show_option_all' => 'All categories'));
    ?>
        <input type="submit" id="searchsubmit" value="Search" />
        </div>
    </form>

    What code would I use to replace the “All categories” default with a default category?

    I looked through the codex and can’t figure out what to replace on the following line:

    wp_dropdown_categories(array('show_option_all' => 'All categories'));

    Thanks,
    Matt

    http://wordpress.org/extend/plugins/relevanssi/

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    You can use the ‘selected’ parameter to choose a default category. So, something like this:

    wp_dropdown_categories(array('selected' => category_ID));

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Dropdown category search: How to set default category?’ is closed to new replies.