I Am Converting Html to Wordpress. I Can Make Simple Searchform through
<?php get_search_form( $echo ); ?>
But I want to show Nothing Found if it can't find any data through search. How Can i Do that , any help?
I Am Converting Html to Wordpress. I Can Make Simple Searchform through
<?php get_search_form( $echo ); ?>
But I want to show Nothing Found if it can't find any data through search. How Can i Do that , any help?
Share Improve this question edited May 16, 2015 at 10:49 Nayeem Hyder Riddhi asked May 16, 2015 at 8:04 Nayeem Hyder RiddhiNayeem Hyder Riddhi 2012 silver badges10 bronze badges1 Answer
Reset to default 1In your index.php
, you should have something a bit like:
<?php if ( have_posts() ) : ?>
<!-- HTML -->
<?php while ( have_posts() ) : the_post() ?>
<!-- Post content -->
<?php endwhile ?>
<!-- HTML -->
<?php endif ?>
You can extend this code to say "if no posts and is search, display message":
<?php if ( have_posts() ) : ?>
<!-- HTML -->
<?php while ( have_posts() ) : the_post() ?>
<!-- Post content -->
<?php endwhile ?>
<!-- HTML -->
<?php elseif ( is_search() ) : ?>
<!-- No posts and is search, show message -->
<?php endif ?>