Site icon Hip-Hop Website Design and Development

Show matching categories in search page

my current search only shows POSTS as results.

http://newslines.org/?s=george

My site has categories for George Clooney, George R.R. Martin etc. How do I get a list of categories that match the search term to show at the top of the results page?

I have tried this:

<?php 
$search_query = get_search_query();

$term = get_term_by( 'name', $search_query, 'category' );
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
    echo "<ul>";
    foreach ( $terms as $term ) {
    echo "<li>" . $term->name . "</li>"; 
    }
    echo "</ul>";
}
;?> 

But I don’t get any output