• How can I limit the basic search functionality to only echo results from specific categories? There’s got to be a way. I want to code it instead of using a plugin because I am having 2 different search forms: one searches through specific categories, the other searches through different categories.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • This thread might be helpful. I haven’t tried out the plugin myself, but the demo looks fantastic.

    Thread Starter mbrumley

    (@mbrumley)

    Thanks…that’s not exactly what I am looking for but it’s cool.

    Maybe there’s the potential to modify the plugin. It might also be an idea to email the plugin author as well ??

    Thread Starter mbrumley

    (@mbrumley)

    I found this which is close…not sure how to implement this.

    www.ads-software.com/support/topic/145593?replies=3

    Try leaving out the minus sign when including the categories, and see if that limits the search to those categories, rather than exclude them.

    So:

    <?php
    if( is_search() )  :
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("s=$s&paged=$paged&cat=1,2,3");
    endif;
    ?>

    Thread Starter mbrumley

    (@mbrumley)

    Thank you for the help. I think this will do the trick!

    You’re welcome! :)Thanks for the feedback! It’s always good to know when a suggestion works

    I don’t know where this code is placed – could you elaborate on the placement of this code and anything else I’d need to know to create a search result on a specific category?

    Thanks so much.

    Hi,
    I was exactly looking for a piece of code to limite the search to certain categories. Your code works well !!

    <?php if( is_search() )  :
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("s=$s&paged=$paged&cat=1,2,3");
    endif; ?>

    But, I want the category to be dynamic :
    From the web page archive.php, I want to store the current category (something like $my_category = “current categorie”) and call this variable in the search result web page search.php (query_posts(“S= …” cat=”.$my_category). As I am a dummy in PHP langage, I don’t know what I need to write …. could you help me?

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limit Search to Specific Categories’ is closed to new replies.