Search filtering by post category
-
Hey Mikko,
I just can’t get this piece of code the work like I want to:
<?php $url = get_bloginfo('url'); $docs = esc_attr(add_query_arg(array('s' => get_search_query(), 'cat' => 61), $url)); $news = esc_attr(add_query_arg(array('s' => get_search_query(), 'cat' => 81), $url)); ?> <aside class="sidenav" role="navigation"> <ul class="sidebar-menu"> <li><strong><?php _e('Filter your results', 'amer-sports') ?></strong></li> <li><?php echo '<a href="' . get_bloginfo('url') . '?s=' . get_search_query() . '&showposts=-1" rel="nofollow">All</a>'; ?></li> <li><?php echo "<a href='$docs'>Documents</a>"; ?></li> <li><?php echo "<a href='$news'>News</a>"; ?></li> </ul> </aside>
The body class changes to right category, but still gives the same results.
Example page https://amer-sports.herokuapp.com/?s=mavic
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Search filtering by post category’ is closed to new replies.