-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.php
More file actions
executable file
·85 lines (70 loc) · 2.55 KB
/
search.php
File metadata and controls
executable file
·85 lines (70 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/* The template that powers the search results page. */
get_header();
// Get number of results
$results_count = $wp_query->found_posts;
?>
<div class="jumbotron">
<div class="container">
<h1>Search <span class="keyword">“<?php the_search_query(); ?>”</span></h1>
<?php if ($results_count == '' || $results_count == 0) { // No Results ?>
<p><span class="label label-danger"><?php _e('No Results'); ?></span> <?php _e('Try different search terms.'); ?></p>
<?php } else { // Results Found ?>
<p><span class="label label-success"><?php echo $results_count . __(' Results'); ?></span></p>
<?php } // end results check ?>
<div class="row">
<div class="col-md-3">
<?php get_search_form(); ?>
</div>
</div>
</div> <!-- .container -->
</div> <!-- .jumbotron -->
<div class="container" id="main">
<div class="row">
<div class="col-md-8">
<?php if (have_posts()) : // Results Found ?>
<h1><?php _e('Search Results'); ?></h1>
<?php while (have_posts()) : the_post(); ?>
<article <?php post_class(); ?>>
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<p><?php echo wp_trim_words( get_the_excerpt(), 30, '...' ); ?></p>
</div>
</article>
<hr />
<?php endwhile; ?>
<ul class="pager">
<li><?php next_posts_link('<i class="fa-chevron-left"></i> Older Results') ?></li>
<li><?php previous_posts_link('Newer Results <i class="fa-chevron-right"></i>') ?></li>
</ul>
<?php else : // No Results ?>
<p><?php _e('Sorry. We couldn’t find anything for that search. View one of our site’s pages or a recent article below.'); ?></p>
<div class="row">
<div class="col-md-6 posts">
<h3><?php _e('Recent Articles'); ?></h3>
<ul>
<?php
$args = array(
'numberposts' => '10',
'post_status' => 'publish'
);
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ) {
echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></li>';
}
?>
</ul>
</div> <!-- .posts -->
<div class="col-md-6 pages">
<h3><?php _e('Page Sitemap'); ?></h3>
<ul>
<?php wp_list_pages('title_li=&sort_column=menu_order'); ?>
</ul>
</div> <!-- .pages -->
</div> <!-- .row -->
<?php endif; ?>
</div> <!-- .col-md-8 -->
<?php get_sidebar(); ?>
</div> <!-- .row -->
</div><!-- .container -->
<?php get_footer(); ?>