Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm interested in a wordpress plug-in that is able to make from tags or categories multiple search criteria like left hand side of the following site system http://www.olx.com/dvd-cat-238 When one of the criteria filter is selected the content displayed should be displayed regarding that selection.

If multiple criteria is selected the displayed content should contain all the selected filter simultaneously.

Best regards

share|improve this question

closed as off-topic by Tom J Nowell Feb 4 at 19:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

4 Answers 4

Just so no one else looses the amount of time I did on this, the code like this:

isset($_POST['cat']

needs to be changed to:

isset($_GET['cat']

because the form is using the 'get' method.

Also, 'category_and' should be 'category_in' if you want to check multiple categories.

share|improve this answer
    
Those argument names are incorrect unfortunately, both should have include double underscores, eg. category__and and category__in. Also you have not made a clear distinction of how the two category arguments differ in functionality. Correct/update both those things in your answer and i'll happily +1 ya.. ;) –  t31os Feb 3 at 20:02
add comment

I started once to write something like that but i never finished it and always customize it for each client that needs this functionality

so enjoy and feel free to use/change any way you want

<?php
/*
Plugin Name: BaInternet Search Filters
Plugin URI: http://www.bainternet.info
Description: filter searches by tags and categories
Version: 0.0.1
Author: bainternet בניית אתרים
Author URI: http://www.bainternet.info
*/
/*
* very early beta so watch out.
*
* Usage: add [search_with_filter] as shortcode to 
*        post/page or widget or call it from a template
*        page like so: echo do_shortcode('search_with_filter');
*
*
*/

function ba_SearchFilter($query) {
    if (!$query->is_search) {
        return $query;
    }
    if (isset($_POST['cat'])){
        $query->set('category__and', $_POST['cat']);
    }
    if (isset($_POST['tags'])){
        $query->set('tag__and', $_POST['tags']);
    }
    return $query;
}
//hook filters to search
add_filter('pre_get_posts','ba_SearchFilter');

function ba_search_with_filters(){
    $out = '<form role="search" method="get" id="searchform" action="'. home_url( '/' ).'">
    <div><label class="screen-reader-text" for="s">Search for:</label>
        <input type="text" value="" name="s" id="s" /><br />';
            $categories=  get_categories(); 
            foreach ($categories as $category) {
                $option = '';
                $option .= '<input type="checkbox" name="cat[]" id="cat[]" value="'.$category->term_id.'"> ';
                $option .= $category->cat_name .'<br />';
                $out.= $option;
            }
            $tags=  get_categories(); 
            foreach ($tags as $tag) {
                $option = '';
                $option .= '<input type="checkbox" name="tags[]" id="tags[]" value="'.$tag->term_id.'"> ';
                $option .= $tag->cat_name .'<br />';
                $out.= $option;
            }
    $out .='<input type="submit" id="searchsubmit" value="Search" />
        </div>
        </form>';
    return $out;
}

add_shortcode('search_with_filter','ba_search_with_filters');

?>
share|improve this answer
    
great plugin, but a quick question. What do i have to change in order for the search to do tag + category rather than search for both tags and category –  user14154 Mar 14 '12 at 20:41
add comment

Look at scribu's plugin Query Multiple Taxonomies.

In addition to making the process of querying within different taxonomies possible in earlier versions of WordPress, it includes a drilldown widget similar to the one you pointed out. If you define your taxonomies well, it can be used to make a very helpful interface for users browsing your site.

share|improve this answer
add comment

Hi I'm know I'm late to the party but I've developed this plugin for this exact purpose:

WordPress Search & Filter - WordPress Plugins

You use a shortcode to generate the interface and works with categories, taxonomies, post types and post dates :)

Hope it helps!

share|improve this answer
    
No idea why I got a vote down?? Yeah I'm plugin' my own plugin, but its completely free and answers the question completely.... ?? Its also one of the few that are currently maintained, unlike the one QMT one above... .Anyway thanks whoever you are! –  acSlater Feb 4 at 16:06
    
Unless the person who down voted wishes to come forward, that information can't be gotten. Your answer would become useless if the URL you posted became broken, or 404'd, and it doesn't actually answer the question. Try providing a solution in your answer, rather than simply linking to one elsewhere. –  Tom J Nowell Feb 4 at 16:41
    
The asker is asking for a plugin "I'm interested in a wordpress plug-in that is able to make from tags or categories multiple search criteria", and I'm linking to a plugin hosted on the wordpress site (its hardly going to go down) so to be honest I can think of no better answer - just think its bad to remove rep when a perfectly good answer has been given and someone has spent time and effort to give that answer.. –  acSlater Feb 4 at 18:31
1  
Ah, I failed to spot the plugin request, plugin recommendations are offtopic on this site, and we advise against posting links as answers as they aren't reliable –  Tom J Nowell Feb 4 at 19:50
add comment