Customizing "No Results" in search.php
-
Hey all! I’ve been customizing my search.php to show the results in the same grid style that I use across the site for content, and I figured it out miraculously. However, I created another issue. If you search for something that doesn’t exist, you don’t get a “no results” message and the page slightly breaks. I’m not fluent in php just know enough to break things. Can anyone help me out? See the code below.
website
http://galeriewestdev.com.s195680.gridserver.com/<?php get_header(); ?> <div id="main-content"> <div class="container"> <div id="content-area" class="clearfix"> <div id="left-area"> <div class="search-info"> <h1 class="search-title"># <?php echo $s ?></h1> </div> <?php $args = array( 's' => $_REQUEST['s'], 'showposts' => -1, 'any' => $searchable_types // define searchable Post Types ); $tp_allsearch = new WP_Query($args); ?> <?php // Start the loop. $posts = array(); // If there are Search posts if($tp_allsearch->have_posts()) : // Go through result while($tp_allsearch->have_posts()) : $tp_allsearch->the_post(); // Save Post ID in array $posts[] = $post->ID; endwhile; else: return false; endif; ?> <?php // Build shortcode with the $post array build before $the_content = do_shortcode('[ess_grid alias="gd2" posts="'.implode(',', $posts).'"]'); // Echo Out the result in your page echo $the_content; ?> </div> <!-- #left-area --> <?php get_sidebar(); ?> </div> <!-- #content-area --> </div> <!-- .container --> </div> <!-- #main-content --> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Customizing "No Results" in search.php’ is closed to new replies.