tags:

views:

28

answers:

2

I am using this code for my search:

<?php


    function wp_search_form($form) {
    $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
    '.wp_dropdown_categories('exclude=1 Categories&hide_empty=0&echo=0&selected='.intval($_GET['cat']).'').'
    <input type="text" class="search_input" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
    <input type="submit" alt="Search" class="greybutton float_right" value="Search" />


    </div>
    </form>';
    return $form;
}

I want to remove the catagory dropdown and instead make it search the current catagory

+2  A: 

Remove the wp_dropdown_categories() call and replace with;

<input type="hidden" name="cat" value="<?php echo $wp_query->get_queried_object_id(); ?>" />

Note if you're using that inside a function, you'll need to globalise $wp_query.

TheDeadMedic
Hmm I can't really get this to work. Can you show exactly what part you replace?
Thomas
+1  A: 
Dennis Pedrie