-
Notifications
You must be signed in to change notification settings - Fork 13
/
search.php
44 lines (37 loc) · 1.07 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
<?php /* Template name: Custom Search */
get_header();
?>
<?php
if($_GET['search_text'] && !empty($_GET['search_text']))
{
$text = $_GET['search_text'];
}
if($_GET['type'] && !empty($_GET['type']))
{
$type = $_GET['type'];
}
?>
<div class="container">
<h4>Searching for: <?php echo $text; ?></h4>
<?php
$args = array(
'post_type' => $type,
'posts_per_page' => -1,
's' => $text,
/*'exact' => true,
'sentence' => true*/
);
$query = new WP_Query($args);
while($query -> have_posts()) : $query -> the_post();
?>
<div class="post clearfix">
<h5><?php the_title(); ?></h5>
<strong>
<?php if(get_post_type() == 'post'){ echo 'Post'; } ?>
<?php if(get_post_type() == 'movies'){ echo 'Movie'; } ?>
<?php if(get_post_type() == 'books'){ echo 'Books'; } ?>
</strong>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
<?php get_footer(); ?>