Support » Plugins » Category filter on Search

  • I’d like to filter my search results by either one of 2 categories on my blog (photos OR videos).but I cant seem to locate any WP plugin which allows the native WP search engine to accept filter-parameters on-category field.
    How should I solve this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • inside search.php you can put something like

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) :  the_post();  ?>
    div class="post">
    <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <div class="entry-content"><blockquote><?php the_excerpt(); ?>
    //////////// look at this  ////
    <?php if ( in_category('1') ) { ?>
    ///////// that's it /////////
    <?php } else {?>
    <p class="postmetadata"><em>Category </em><?php the_category(', ') ?> | 
    <?php } ?>
    <?php  endwhile;  ?>

    How does this work? Will it only display results for things that are in category 1?

    Is there a way to make the search function work only in the category you’re currently in?

    So if I’m browsing category 7 and preform a search, then the results page would only show results that matched my query in category 7?

    You’re probably looking for this:

    I left a comment at the author’s page when he said he was going to come up with that widget and he was very kind to email me today to inform me its out!

    I used it, and it works well for me, I’m using WP 2.6

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category filter on Search’ is closed to new replies.