Search filter not working!
-
My search result page has a filter dropdown with all Post Types including cool_timeline.
<select name="post_type"> <option value="">All Content Types</option> <option value="post">Posts</option> <option value="page">Pages</option> <option value="cool_timeline">Timeline Stories</option> <option value="product">Products</option> <option value="event">Events</option> <option value="resource">Resources</option> </select>
The code that creates the above dropdown is as follows:
<select name="post_type"> <option value="">All Content Types</option> <?php foreach (get_post_types(['exclude_from_search' => false], 'objects') as $post_type) : ?> <?php if ($post_type->name !== 'attachment') : ?> <option value="<?php echo $post_type->name ?>" <?php if (isset($_GET['post_type']) && $_GET['post_type'] === $post_type->name) echo 'selected' ?> ><?php echo $post_type->labels->name ?></option> <?php endif ?> <?php endforeach ?> </select>
Timeline Stories are displaying fine in the search result, but all content type filters are working perfectly (i.e. filtering the result properly based on selected post type and presenting the new filtered result) except cool_timeline. When I use this filter, the result page jumps back to site’s homepage.
Search result page screenshot
I looked into all templates but did not find anything that can cause this. I have gone completely clueless!
The site is built with a custom Block theme and using full site Editing.
- The topic ‘Search filter not working!’ is closed to new replies.