WordPress.org

Ready to get started?Download WordPress

Forums

Category filter on Search (4 posts)

  1. computational_man
    Member
    Posted 6 years ago #

    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?
    Thanks!

  2. nonletter
    Member
    Posted 6 years ago #

    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 } ?>
    </blockquote></div>
    </div>
    
    <?php  endwhile;  ?>
  3. noelgreen
    Member
    Posted 6 years ago #

    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?

  4. girl.mg
    Member
    Posted 5 years ago #

    You're probably looking for this:

    http://wordpress.org/extend/plugins/multiple-category-selection-widget/

    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

Topic Closed

This topic has been closed to new replies.

About this Topic