Adding “No results found” and/or other content to the Search results page
-
I am not a strong PHP coder and am having issues adding this functionality to my search results page. I can follow the normal if/else statements that are found online but the theme i am using has added complexity and every time i try to add an if statement to tell it what to display when found_posts<1 it just breaks the whole page. Can someone please give me a hint or show me what to input where?
Search page code is as follows:
<?php get_header(); global $wp_query; ?> <div style="background: #fff;" id="container"> <div style="background: #fff;" class="container"> <div class="row"> <div class="col-sm-12"> <?php if ( have_posts() ) { ?> <div class="page-title"> <h1><?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>"</h1> </div> <?php while ( have_posts() ) { the_post(); $post_excerpt = substr(get_the_excerpt(), 0,240); $post_excerpt = str_replace('Description', '', $post_excerpt);?> <div class="row"> <?php if (has_post_thumbnail()):?> <div class="col-sm-2"> <a>"> <?php the_post_thumbnail('medium') ?> </a> </div> <div class="col-sm-10"> <h3><a>"> <?php the_title(); ?> </a></h3> <?php echo $post_excerpt .'...'; ?> <div class="read-more"> <a>">Read More</a> </div> </div> <?php else: ?> <div class="col-sm-12"> <h2> <a>"> <?php the_title(); ?> </a> </h2> <?php echo $post_excerpt; ?> <div class="read-more"> <a>">Read More</a> </div> </div> <?php endif; ?> </div> <hr> <?php } ?> <?php paginate_links(); ?> <?php } ?> </div> </div> </div> </div> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Adding “No results found” and/or other content to the Search results page’ is closed to new replies.