-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
57 lines (45 loc) · 1.92 KB
/
search.php
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
<?php
/*
Template Name: Search Page
*/
?>
<?php
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="alert alert-success" >
<?php echo get_bloginfo( 'description' );?>
<p><?php echo the_tags(_x( 'Tags', 'Used before tag names.','stackdesign'),' , ' ); ?></p>
</div>
<?php get_search_form(); ?>
<?php
global $query_string;
$search_query = wp_parse_str( $query_string );
$search = new WP_Query( $search_query );
?>
<?php
if ( have_posts() ) :
$total_results = $wp_query->found_posts;
echo '<div class="alert alert-success" >'.sprintf(__( 'Search Results for: %s', 'stackdesign' ),$total_results).'</div>';
// Start the loop.
while ( have_posts() ) :
the_post();
global $wp_query;
get_template_part( 'content', get_post_format() );
// End the loop.
endwhile;
// Previous/next page navigation.
the_posts_pagination(array('screen_reader_text'=> __( 'Posts navigation', 'stackdesign' ),
'prev_text' => __( 'Previous page', 'stackdesign' ),
'next_text' => __( 'Next page', 'stackdesign' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'stackdesign' ) . ' </span>', ));
else :
get_template_part( 'content', 'none' );
echo' <div class="alert alert-warning" ><p>'.__( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'stackdesign' ).'</p></div>';
endif;
?>
</main>
</div>
</div>
<?php get_footer();?>