If search matches taxonomy
I only wanted to match tags in a single taxonomy, so I was able to simplify the code as follows. My taxonomy is ‘post_tag’ — just swap yours out as needed. $i = 0; $search_query = get_search_query(); $term = get_term_by( ‘name’, $search_query, ‘post_tag’ ); if( $term !== false ) { $i++; $single_result = $term; } … Read more