-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
84 lines (74 loc) · 2.14 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
<?php
if ($_POST) {
$list = array();
$item = array();
foreach($_POST as $key => $value){
if($value != ''){
$item['taxonomy'] = htmlspecialchars($key);
$item['terms'] = htmlspecialchars($value);
$item['field'] = 'slug';
$list[] = $item;
}
}
$cleanArray = array_merge(array('relation' => 'AND'), $list);
print_r($cleanArray);
}
?>
<?php get_header(); ?>
<main class="flex-fill" id="search-results">
<div class="container mt-4">
<div class="row">
<div class="col-md-12">
<header class="page-header">
<h1 class="page-title">
<?php printf( __( 'Search Results for: %s', 'xniz' ), get_search_query() ); ?>
</h1>
</header>
<hr>
</div>
</div>
<?php if (have_posts()) : while(have_posts()) : the_post(); ?>
<?php
$thumbnail_url = get_the_post_thumbnail_url();
if ($thumbnail_url == null) {
$thumbnail_url = get_template_directory_uri() . '/images/image-thumbnail-2.png';
}
?>
<div class="row mb-4">
<div class="col-sm-12 col-md-4 col-lg-4">
<img src="<?php echo $thumbnail_url;?>" alt="" class="img-fluid mb-3 thumbnail">
</div>
<div class="col-sm-12 col-md-8 col-lg-8">
<h3><a class="text-secondary" href="<?php echo get_permalink(); ?>">
<?php the_title(); ?>
</a></h3>
<hr>
<?php
$excerpt = get_the_excerpt();
?>
<?php if ($excerpt) : ?>
<p class="mb-0"><?php echo $excerpt; ?></p>
<?php else: ?>
<p class="mb-0">There is no description available.</p>
<?php endif;?>
<a class="btn btn-primary mt-2 view-result" href="<?php the_permalink(); ?>">View Result</a>
</div>
</div>
<?php endwhile; ?>
<div class="row pb-4">
<div class="col-12">
<?php echo paginate_links(); ?>
</div>
</div>
<?php else: ?>
<div class="row">
<div class="col-12">
<p>No search results</p>
<a href="/" class="btn btn-primary">Go home</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
</main>
<?php get_footer(); ?>