Ejemplo n.º 1
0
    /**
     * Search page loop template part.
     *
     * Used in theme search.php template file.
     *
     * @since 0.1.0
     */
    public function search_page_loop($s, $args = array())
    {
        global $wp_query;
        // used to access total number of search results
        $args = extract($this->merge_loop_arguments($args));
        $date_sep = '';
        $total_results = $wp_query->found_posts;
        ?>

		<?php 
        if (have_posts()) {
            ?>

			<h2 id="search-results-header" class="entry-title"><?php 
            _e('Search results for', 'wpgothemes');
            echo ' \'' . $s . '\'';
            ?>
</h2>
			<div id="search-matches"><?php 
            printf(_n('%d match found', '%d matches found', $total_results, 'wpgothemes'), $total_results);
            ?>
</div>

			<hr id="search-hr">

			<?php 
            while (have_posts()) {
                the_post();
                ?>

				<?php 
                // Code to show search terms highlighted
                $keys = explode(" ", $s);
                $title = get_the_title();
                $content = WPGo_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);
                ?>

				<article id="post-<?php 
                the_ID();
                ?>
" <?php 
                post_class();
                ?>
>

					<header>

						<?php 
                $no_title = __('(no title)', 'wpgothemes');
                ?>

						<?php 
                WPGo_Utility::check_empty_post_title(get_the_ID(), 'h3', $no_title, 'search-loop-header');
                ?>

						<?php 
                if ($render_date) {
                    ?>
							<div class="post-meta post-meta-inline">
								<?php 
                    WPGo_Hooks::wpgo_post_archive_meta_header();
                    ?>
								<?php 
                    if ($render_date) {
                        ?>
									<time class="date" datetime="<?php 
                        the_date('c');
                        ?>
" pubdate><?php 
                        the_time(get_option('date_format'));
                        ?>
</time><?php 
                        echo $date_sep;
                    }
                    ?>
							</div><!-- .post-meta -->
						<?php 
                }
                ?>

					</header>

					<?php 
                WPGo_Hooks::wpgo_before_post_archive_content();
                ?>

					<div class="post-content">
						<?php 
                echo $content;
                ?>
						<?php 
                wp_link_pages(array('before' => '<div class="page-link">', 'after' => '</div>'));
                ?>
					</div>
					<!-- .post-content -->

				</article> <!-- .post -->

			<?php 
            }
            // end of the loop.
            ?>

			<?php 
            WPGo_Utility::paginate_links();
            ?>

		<?php 
        } else {
            ?>

			<div id="post-0" class="post no-results not-found">

				<h2 class="entry-title"><?php 
            _e('No search results found...', 'wpgothemes');
            ?>
</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.', 'wpgothemes');
            ?>
</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', 'wpgothemes');
            ?>
</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', 'wpgothemes');
            ?>
</h3>
					<ul>
						<?php 
            //wp_list_cats();
            wp_list_categories();
            ?>
					</ul>
				</div>

			</div><!-- #post-0 -->

		<?php 
        }
        ?>

	<?php 
    }