Support » Themes and Templates » Restrict Categories on Search Page?

  • Resolved bcreighton



    Is there anyway to exempt certain categories from being searched? I tried using query_posts() but it seemed to pulling all of those entries instead.


Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    if( is_search() )  :
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    s=$s” is the key for this query; $s is a global variable in WordPress that holds the search phrase. Just change “cat=-1,-11,-101” to list the categories you need excluded (minus sign before each, naturally). That $paged part is explained here:

    Perfect! Thank you! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restrict Categories on Search Page?’ is closed to new replies.