-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.php
107 lines (101 loc) · 3.73 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!-- Include Header -->
<?php get_header(); ?>
<!-- === MODAL INSURANCE TYPES === -->
<?php echo do_shortcode('[merlin-dialler-modal-list]'); ?>
<!-- === FORM === -->
<?php echo do_shortcode('[merlin-dialler-form]'); ?>
<!-- Section Hero Resources -->
<section class="s-hero-resources">
<div class="container">
<div class="s-hero-resources-title">
<h1>Results from your search</h1>
<p>Word searched: <?php echo get_query_var('s') ?></p>
</div>
</div>
</section>
<!-- Section Navigation Resources -->
<section class="s-navigation-resources">
<div class="container">
<ul class="s-navigation-resources-list">
<li>
<a href="<?php echo get_permalink(get_page_by_title('Resources')) ?>">
<i class="fa-solid fa-book"></i>
<p>All Resources</p>
</a>
</li>
<li>
<a href="<?php echo get_category_link(59); ?>">
<i class="fa-solid fa-pager"></i>
<p>Blog</p>
</a>
</li>
<li>
<a href="<?php echo get_category_link(15); ?>">
<i class="fa-solid fa-circle-info"></i>
<p>Support</p>
</a>
</li>
</ul>
</div>
</section>
<!-- Section Main Content -->
<section class="s-main-content">
<div class="container">
<!-- List all posts -->
<div class="s-all">
<!-- Code to create query and search for posts -->
<?php
global $query_string;
$query_args = explode("&", $query_string);
$search_query = array();
foreach($query_args as $key => $string) {
$query_split = explode("=", $string);
$search_query[$query_split[0]] = urldecode($query_split[1]);
}
$the_query = new WP_Query($search_query);
if ($the_query->have_posts()) :
?>
<div class="alm-listing">
<?php if(have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<a href="<?php the_permalink(); ?>" class="card-post-default">
<div class="image">
<?php the_post_thumbnail(); ?>
</div>
<div class="info">
<!-- Category Section -->
<?php
$category = get_the_category($post -> ID); // return ID post
if(!empty($category)){
foreach($category as $nameCategory){
echo '<span class="categorie">' .$nameCategory -> name.'</span>';
}
}
?>
<!-- End of Category Section -->
<h6><?php the_title(); ?></h6>
<ul>
<li>
<span><?php echo get_the_date('j, F'); ?></span>
</li>
<li>
<span><?php echo do_shortcode('[rt_reading_time postfix="min" postfix_singular="min"]') ?> of read</span>
</li>
</ul>
</div>
</a>
<?php endwhile; else : endif; ?>
</div>
<?php wp_reset_postdata(); ?>
<!-- else -->
<?php else: ?>
<div class="empty-search">
<h2>Result not found</h2>
<p>It wasn't found any result based on your search.</p>
</div>
<?php endif; ?>
<!-- End of IF statement -->
</div>
</div>
</section>
<!-- Include Footer -->
<?php get_footer(); ?>