最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How Can I Make Dynamic Search Form While Converting Html To Wordpress?

programmeradmin2浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

In 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 ?>
发布评论

评论列表(0)

  1. 暂无评论