<?php if ( isset( $_GET['s'] ) ) : ?>
<h2 class="black">
<?php
echo sprintf( __( '%s Search Results for ', 'html5blank' ), $wp_query->found_posts );
echo get_search_query();
?>
</h2>
<?php elseif ( isset( $_GET['s'] ) == null ) : ?>
<h2 class="red">
<?php
echo sprintf( __( '%s Search Results for ', 'html5blank' ), $wp_query->found_posts );
echo get_search_query();
?>
</h2>
<?php else : ?>
<h2 class="empty">Search <?php echo get_theme_mod( 'theme_options_name', '' ); ?></h2>
<?php endif ?>
I cant get the elseif to turn red when no results are returned.
www.site.com/?s=hello
the first is a search that returns posts, this is black
the second is a search that returns no posts, this should be red
the third is an empty search, this is black.
2
Answers
Please use like below code:
First of all, you have a lot of mistakes/typos in your code.
echo
isechoe
__()
function starting with double quotes__("
but ending with single quote')
</h2>
is wrong in the first two cases.after fixing all those things, the code with your expected results will be like this: