I have a search function on my blog. If I enter a value, say ‘fruits’ in the search box and it doesn’t match in any of the posts but it is the name of a category in the blog then I want the posts that belong to that category to be displayed.

Is it possible to amend the search functionality so it covers the searching of all categories and possibly tags in the blog too?

Many thanks.

2 Answers
2

// Above the loop on your search result template:
if ( is_search() ) // Are we on a search result page?
{
    global $wp_query, $query_string;
    // now modify/filter the query (result)
    query_posts( $query_string . 'cat=1&tag=apples+apples' );
}

Leave a Reply

Your email address will not be published. Required fields are marked *