Search in current category
-
Here’s a little feature I added to my blog: offering a search form for the category that is currently being viewed:
<?php if (is_category()) { $cat_obj = $wp_query->get_queried_object(); $cat_slug = $cat_obj->category_nicename; $search_cat = 'https://www.domain.org/category/' . $cat_slug . '/'; ?> <form method="get" id="searchform" action="<?php $search_cat ?>"> <input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id=s> <input type="submit" id="searchsubmit" value="Search <?php single_cat_title(); ?>"> </form> <?php } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Search in current category’ is closed to new replies.