/
search.php
117 lines (106 loc) · 4.28 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
108
109
110
111
112
113
114
115
116
117
<?php get_header(); ?>
<?php
global $query_string;
$searching_events = strpos($query_string, 'event-type=');
$searching_projects = strpos($query_string, 'project-event=');
$searching_data = strpos($query_string, 'data-category=');
$searching_challenge = strpos($query_string, 'challenge-category=');
?>
<?php
if ($searching_events !== false) { ?>
<?php include('searchbar-event.php'); ?>
<section>
<div class="container cf">
<h3>Events containing: <em><?php the_search_query(); ?></em></h3>
<?php
if ( have_posts() ) :
include('loop-event.php');
else: ?>
<p>Sorry, no results found for <strong><?php echo get_search_query(); ?></strong>.</p>
<p>Questions? Check out our <a href="<?php bloginfo('url'); ?>/about/faq/">FAQ</a> or feel free to <a href="<?php bloginfo('url'); ?>/contact/">get in touch</a>!</p>
<?php endif; ?>
</div>
</section>
<?php } elseif ( $searching_projects !== false ) { ?>
<?php include('searchbar-project.php'); ?>
<section>
<div class="container cf">
<h3>Projects containing: <em><?php the_search_query(); ?></em></h3>
<?php
$found_projects = false;
$query_event = get_page_by_path(get_query_var('project-event'), OBJECT, 'event');
$search_q = get_search_query();
if ( have_posts() )
include('loop-project.php');
if (!have_posts() || !$found_projects): ?>
<p>Sorry, no results found <?php if (!empty($search_q)) echo 'for <strong>'.$search_q.'</strong>'; ?> for the event <strong><?php echo $query_event->post_title; ?></strong>.</p>
<?php endif; ?>
</div>
</section>
<?php } elseif ( $searching_data !== false ) { ?>
<?php include('searchbar-data.php'); ?>
<section>
<div class="container cf">
<h3>Datasets containing: <em><?php the_search_query(); ?></em></h3>
<?php
if ( have_posts() ) :
include('loop-data.php');
else:
echo '<p>Sorry, no results found for <strong>' . get_search_query() . '</strong></p>';
endif; ?>
</div>
</section>
<?php } elseif ( $searching_challenge !== false ) { ?>
<?php include('searchbar-challenge.php'); ?>
<section>
<div class="container cf">
<h3>Challenges containing: <em><?php the_search_query(); ?></em></h3>
<?php
if ( have_posts() ) :
include('loop-challenge.php');
else:
echo '<p>Sorry, no results found for <strong>' . get_search_query() . '</strong></p>';
endif; ?>
</div>
</section>
<?php } else { ?>
<div class="container cf">
<div class="main-col">
<h3>Search Results For: <em><?php the_search_query(); ?></em></h3>
<?php
if(have_posts()) :
while(have_posts()) : the_post(); ?>
<div class="post">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php if ( has_post_thumbnail() ) {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'excerpt-thumb' );
echo '<img src="' . $thumb['0'] . '" alt="" />';
} ?>
<?php the_excerpt(); ?>
<p class="meta">
<a href="<?php the_permalink(); ?>" class="btn">Read More</a>
</p>
</div>
<?php endwhile; ?>
<?php if(function_exists('wp_paginate')) { ?>
<div class="pagination cf">
<?php wp_paginate(); ?>
</div>
<?php } else { ?>
<div class="pagination cf">
<div class="posts-nav older"><?php next_posts_link('Older <span>></span>', 0); ?></div>
<div class="posts-nav newer"><?php previous_posts_link('<span><</span> Newer', 0); ?></div>
</div>
<?php } ?>
<?php
else :
echo '<p>Sorry, no results found for <strong>' . get_search_query() . '</strong></p>';
endif;
?>
</div><!-- /main-col -->
<div class="sidebar">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('blog-sidebar') ) {} ?>
</div>
</div><!-- /container -->
<?php } ?>
<?php get_footer(); ?>