/** * Search page loop template part. * * Used in theme search.php template file. * * @since 0.1.0 */ public static function search_page_loop($s) { ?> <?php if (have_posts()) { ?> <h2 class="entry-title"><?php _e('Search results...', 'presscoders'); ?> </h2> <?php while (have_posts()) { the_post(); ?> <?php // Code to show search terms highlighted $keys = explode(" ", $s); $title = get_the_title(); $content = PC_Utility::n_words(wp_strip_all_tags(get_the_content()), 300); $title = preg_replace('/(' . implode('|', $keys) . ')/iu', '<span class="search-results">\\0</span>', $title); $content = preg_replace('/(' . implode('|', $keys) . ')/iu', '<span class="search-results">\\0</span>', $content); ?> <div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <h2 class="entry-title"><a href="<?php the_permalink(); ?> " rel="bookmark"><?php echo $title; ?> </a></h2> <?php echo $content; ?> <div class="post-meta"> <?php PC_Hooks::pc_post_meta(); /* Framework hook wrapper */ ?> <p> <span class="date"><?php the_time('M j, Y'); ?> </span> <span class="categories"><?php the_category(', '); ?> </span> <?php if (comments_open()) { ?> <span class="comments"><a href="<?php the_permalink(); ?> #comments" title="<?php the_title_attribute(); ?> "><?php comments_number('Leave a Comment', '1 Comment', '% Comments'); ?> </a></span> <?php } ?> </p> </div><!-- .post-meta --> </div> <!-- post-item --> <?php } // end of the loop. ?> <?php } else { ?> <div id="post-0" class="post no-results not-found"> <h2 class="entry-title"><?php _e('No search results found...', 'presscoders'); ?> </h2> <p><?php _e('Sorry, but nothing matched your search criteria. Please try again with some different keywords. Or, choose from the links below to navigate to another page.', 'presscoders'); ?> </p> <div style="margin:0 auto;width:300px;"><?php get_search_form(); ?> </div> <div class="widget" style="width:260px;float:left;"> <h3 class="widget-title"><?php _e('Pages', 'presscoders'); ?> </h3> <ul> <?php wp_list_pages('title_li='); ?> </ul> </div> <div class="widget" style="width:260px;float:right;"> <h3 class="widget-title"><?php _e('Post Categories', 'presscoders'); ?> </h3> <ul> <?php //wp_list_cats(); wp_list_categories(); ?> </ul> </div> </div><!-- #post-0 --> <?php } ?> <?php }