-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
63 lines (57 loc) · 2.84 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
58
59
60
61
62
63
<?php get_header(); ?>
<main role="main" <?php if (get_theme_mod('searchresults_sidebar', true)) echo 'class="blog_layouts_has_sidebar"' ?>>
<section class="blog_layouts_content_spacer">
<div class="blog_layouts_search_container" id="blog_layouts_main_content">
<?php
$blog_layouts_search_query = get_search_query();
$blog_layouts_args = array(
'post_type' => 'post',
'posts_per_page' => -1,
's' => $blog_layouts_search_query,
);
$blog_layouts_query = new WP_Query($blog_layouts_args);
if ($blog_layouts_query->have_posts()) {
echo '<h1 class="blog_layouts_search_headline">' . sprintf(esc_html__('Search results for "%s"', 'blog-layouts'), esc_html($blog_layouts_search_query)) . '</h1>';
$searchresults_style = get_theme_mod('searchresults_style', 'search-engine');
require_once get_template_directory() . '/template-parts/layout-manager.php';
echo blog_layouts_display_posts_list($blog_layouts_query, $searchresults_style);
// Pagination only if needed
if ($wp_query->max_num_pages > 1) {
?>
<div class="blog_layouts_pagination blog_layouts_shadow">
<div class="blog_layouts_pagination_content">
<div class="blog_layouts_pagination_controls">
<?php previous_posts_link(__('« Previous', 'blog-layouts')); ?>
</div>
<div class="blog_layouts_pagination_pages">
<?php
echo paginate_links(array(
'total' => $wp_query->max_num_pages,
'current' => $paged,
'prev_next' => false,
));
?>
</div>
<div class="blog_layouts_pagination_controls">
<?php next_posts_link(__('Next »', 'blog-layouts'), $wp_query->max_num_pages); ?>
</div>
</div>
</div>
<?php
}
wp_reset_postdata();
} else {
echo '<h1>' . __('No posts found.', 'blog-layouts') . '</h1>';
}
?>
</div>
</section>
</main>
<?php
if(get_theme_mod('searchresults_sidebar', true)) {
echo '<aside id="blog_layouts_sidebar" class="' . 'blog_layouts_sidebar_layout_' . esc_attr(get_theme_mod('searchresults_sidebar_layout', 'social')) . '">';
get_sidebar();
echo '</aside>';
}
?>
<?php get_footer(); ?>