• I am using checkboxes to select categories to search:

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
    <input type="submit" id="searchsubmit" value="Search" />
    <input type="text" name="s" id="s"  <?php if(is_search()) { ?>value="<?php the_search_query(); ?>" <?php } else { ?>value="Insert search term &hellip;" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"<?php } ?> />
    
    <?php $query_types = get_query_var('post_type'); ?>
    
    <input type="checkbox" name="cat" value="8" /><label>Category 8</label>
    <input type="checkbox" name="cat" value="9" /><label>Category 9</label>
    
    </form>

    It produces URL:
    http:/page/?s=Searchterm&cat=8&cat=9

    But I need search in multiple categories, so I need this URL:

    http:/page/?s=Searchterm&cat=8,9

    How can I change amperstand separated categories to comma separated?

The topic ‘Search in mutiple categories – URL’ is closed to new replies.