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:


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?



            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; 

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

//Einträge zählen



  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.