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 am currently creating the process of a function which allows one to refine results, Namely by category. Similar to themeforest.net refine the search results.

When i gave as search term "Hello" and search in Category A, D, F, E, than are the filter displayed by the results (in those categories only where the search indeed available), and then when one press on the filter by Category D, then refines it the search results and shows only the result from the Category D.

My only problem is that when my Url shows like this and i search by this cats:

...&orderby=relevance&order=desc&adv_tag=0&adv_cat_52=on&adv_cat_57=on&adv_cat_58=on&adv_cat_53=on&adv_cat_56=on&...

then is the problem, that when i click on the refine filter, that this cats in the url not removed, but the clicked cat is added to the url. when i remove the other cats, then works as excepted. With which Rewrite/Remove Rule/Function can i solved this problem. I think with remove_query_arg or?

<?php 

$filter_cats=array();
$i=0;

            while (have_posts()) : the_post();
                foreach((get_the_category()) as $category) {

$id = $category->term_id;
$cat = 'adv_cat_'.$id.'';

$base_url = remove_query_arg(array($cat));

$url = $base_url;

$url = $url;


$categores =  '<a href="'.$url.'&adv_cat_'.$category->cat_ID.'"><i>'.$category->cat_name.'</i></a>'; 

                $filter_cats[$i] = $categores; 
                $i++;
                }
            endwhile;   



$filter_cats = array_map("unserialize", array_unique(array_map("serialize", $filter_cats)));




//Einträge zählen

$anzahl=count($filter_cats);



$i=0;
while($i<$anzahl){


        echo"<fieldset>{$filter_cats[$i]}</fieldset></br>";
        $i++;
}
share|improve this question
    
I'm sorry. It almost sounds like you have fixed the issue. What is the question? –  s_ha_dum Feb 15 '13 at 0:22
    
Sorry i expressed my problem not good, i mean that if i delete the old adv_cats in the url manually and the new cat what refine the search results is add, then its works, but when i clicked only on the filter than removes the other cats not from the url. when i come home, i send a live preview what i mean exactly. –  jamal Feb 15 '13 at 13:31
    
So i solved this problem with remove query arg, but the other problem here is, that only one cat from the url removed, only those cat query which the search refines. Standard URL: ...&adv_cat_52=on&adv_cat_57=on&adv_cat_58=on&adv_cat_53=on&adv_cat_56=on&... After Click on the Category with the ID 52: ...&adv_cat_57=on&adv_cat_58=on&adv_cat_53=on&adv_cat_56=on&...&adv_cat_52=on But others where not removed, but this must be done, so that only CAT 52 is in the url. When one search in Categorys A & B and click on category A, then shows not the posts from A, but from B. –  jamal Feb 15 '13 at 17:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.