Home / category / Add dropdown to search by all categories or define a specific category
  • How to Add dropdown to search by all categories or define a specific category

    no thumbnail sorry: Add dropdown to search by all categories or define a specific category

    Adding this snippet to your wordpress theme will allow users to search your website but also allow them to select a specific category as well. By modifying the arguments within “wp_dropdown_categories” you can exclude categories or even specify the specific order of categories within the list. The following options are available:

    show_option_all, show_option_none, orderby, order, show_count, hide_empty, child_of, exclude, echo, selected, hierarchical, name, id, class, depth, tab_index, taxonomy, hide_if_empty wordpress codex ( click code to copy )

    wordpress snippet : PHP

    <>
    <form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>">
      <div>
        <label class="screen-reader-text" for="s">Search for:</label>
        <input type="text" value="" name="s" id="s" />
        in <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?>
        <input type="submit" id="searchsubmit" value="Search" />
      </div>
    </form>
    

    ( WordPress codex functions, hooks, in this snippet. )

    siteurl, bloginfo, wp_dropdown_categories, selected, _n, _e, wp,