Tagged: search results
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
December 7, 2013 at 7:16 pm #197390
I hacked up the search results to include tags in the search
file: wp-content\themes\enfold\framework\php\function-set-avia-frontend.php
elseif (is_search()) { //start hack global $wp_query; $orig_query_found=false; $tag_query_found=false; $orig_query = $wp_query; if($orig_query->found_posts){ // echo 'had a post for normal search<br/>'; $orig_query_found=true; }else{ // echo 'no results for normal search<br/>'; $orig_query_found=false; } wp_reset_query(); query_posts( 'tag='.$_GET['s'].'' ); $tag_query = $wp_query; wp_reset_query(); if($tag_query->found_posts){ // echo 'had a post for tag search<br/>'; $tag_query_found=true; }else{ // echo 'no results for tag search<br/>'; $tag_query_found=false; } // $wp_query=$orig_query; switch($orig_query_found){ case true: switch($tag_query_found){ case true: // echo 'should combine the array'; $wp_query->posts = array_merge( $orig_query->posts, $tag_query->posts ); // $wp_query=array_merge($orig_query,$tag_query); break; default: // echo 'leave original results'; $wp_query=$orig_query; break; } break; default: $wp_query->posts = $tag_query->posts ; //since no results in original, just return the tag search break; } //end hack if(!empty($wp_query->found_posts))Now have no errors if:
- no tag results but normal search results
- tag results but no normal search results
- no tag results and no normal search results
- tag results and normal search results
-
This topic was modified 11 years, 11 months ago by
brandonguy.
December 8, 2013 at 9:27 am #197670Hi brandonguy!
Thanks for sharing your changes :)
Cheers!
Devin -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- The topic ‘Added Tags to Search results’ is closed to new replies.
