forked from WPBuddy/largo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
89 lines (79 loc) · 2.42 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
<?php
/**
* The template for displaying Search Results pages.
*/
get_header();
?>
<div id="content" class="stories search-results span8" role="main">
<?php if (of_get_option('use_gcs') && of_get_option('gcs_id')) { ?>
<h1>
<?php
printf( __('Search results for <span class="search-term">%s</span>', 'largo'), get_search_query() );
?>
</h1>
<div class="gcs_container">
<script>
(function() {
var cx = '<?php echo of_get_option('gcs_id'); ?>';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox
gname="largoGCSE"
overlayResults="false"
queryParameterName="s"></gcse:searchbox>
<?php if (is_search()) { ?>
<gcse:searchresults
gname="largoGCSE"
overlayResults="false"
queryParameterName="s"></gcse:searchresults>
<?php } ?>
<?php if (is_search() && !isset($_GET['s'])) { ?>
<script type="text/javascript">
(function() {
var setQuery = function() {
var query = '<?php echo get_search_query(); ?>';
google.setOnLoadCallback(function() {
var el = google.search.cse.element.getElement('largoGCSE');
el.execute(query);
});
};
window.__gcse = {
callback: setQuery
};
}());
</script>
<?php } ?>
</div>
<?php } else { ?>
<?php if ( have_posts() ) {
get_search_form(); ?>
<h3 class="recent-posts clearfix">
<?php
printf( __('Your search for <span class="search-term">%s</span> returned ', 'largo'), get_search_query() );
printf( _n( '%s result', '%s results', $wp_query->found_posts ), number_format_i18n( $wp_query->found_posts ) );
printf( '<a class="rss-link" href="%1$s"><i class="icon-rss"></i></a>', get_search_feed_link() );
?>
</h3>
<?php
while ( have_posts() ) : the_post();
if ( get_post_type( $post ) == 'argolinks' ) {
get_template_part( 'partials/content', 'argolinks' );
} else {
get_template_part( 'partials/content', 'search' );
}
endwhile;
largo_content_nav( 'nav-below' );
} else {
get_template_part( 'partials/content', 'not-found' );
}
} ?>
</div><!--#content-->
<?php get_sidebar(); ?>
<?php get_footer();