-
Notifications
You must be signed in to change notification settings - Fork 16
/
search.php
170 lines (96 loc) · 4.34 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* The template for displaying Search Results pages.
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
/**
* The same as Wordpress's get_template_part, but it accepts a WP_Query object as its first variable so that you can use loop templates
*
* @param object $query WP_Query object
* @param string $template1 template name base
* @param string $template2 template name
* @return gets the template part with $query as its query
*/
function get_loop_template( $query = null, $template1 = null, $template2 = null ) {
if ( !$template1 || !$query )
return;
global $wp_query;
$wp_query = $query;
get_template_part($template1, $template2);
wp_reset_query();
}
$searchterm = get_search_query();
$pageQuery = new WP_Query(array(
'post_type' => array('page'),
's' => $s,
'posts_per_page' => -1,
'paged' => $paged
)
);
$numPages = $pageQuery->post_count;
$chartQuery = new WP_Query(array(
'post_type' => array('chart','post'),
's' => $s,
'posts_per_page' => -1,
'paged' => $paged
)
);
$numCharts = $chartQuery->post_count;
$numTotal = $numCharts + $numPages;
?>
<?php get_header(); ?>
<?php
// $searchterm = get_search_query();
// // $mySearch =& new WP_Query("s=$s & showposts=-1");
// // $mySearch = new WP_Query("$query_string&post_type=post,chart,page&showposts=-1");
// $mySearch = new WP_Query("s=$searchterm&post_type=post,chart,page&showposts=-1");
// $numtotal = $mySearch->post_count; // overridden below
// wp_reset_query();
// $searchterm = get_search_query();
// // $mySearch =& new WP_Query("s=$s & showposts=-1 & post_type=post");
// // $mySearch = new WP_Query("$query_string&showposts=-1&post_type=post,chart");
// $mySearch = new WP_Query("s=$searchterm&showposts=-1&post_type=post,chart");
// $numcharts = $mySearch->post_count;
// wp_reset_query();
// // $searchterm = get_search_query();
// // // $mySearch =& new WP_Query("s=$s & showposts=-1 & post_type=page");
// // // $mySearch = new WP_Query("$query_string&showposts=-1&post_type=page");
// // $mySearch = new WP_Query("s=$searchterm&showposts=-1&post_type=page");
// // wp_reset_query();
// // $numpages = $mySearch->post_count;
// $numtotal = $numpages + $numcharts;
// $numtotal = $wp_query->post_count;
?>
<!-- <h2 class="sp-header"><?php echo $taxonomy; /*** This is the title of the taxonomy -- such as "Subjects" or "Demographics" ***/ ?></h2> -->
<div id="intro">
<!-- <h1>Search results for "<?php echo $searchterm; ?>" <span style="color:#aaa;">(<?php echo $numtotal; ?>)</span></h1> -->
<h1>Search results for "<?php echo $searchterm; ?>" <span style="color:#aaa;">(<?php echo $numTotal; ?>)</span></h1>
<?php
// $query = query_posts("s=$searchterm&posts_per_page=-1&post_type=page");
// $num = $query->post_count;
?>
<!-- <h3 class="search"><?php echo $numpages; ?> page<?php if ($numpages!=1) echo 's'; ?> and <?php echo $numcharts; ?> chart<?php if ($numcharts!=1) echo 's'; ?> were found.</h3> -->
<h3 class="search"><?php echo $numPages; ?> page<?php if ($numPages!=1) echo 's'; ?> and <?php echo $numCharts; ?> chart<?php if ($numCharts!=1) echo 's'; ?> were found.</h3>
<?php // get_template_part( 'loop', 'search' ) ?>
<?php get_loop_template( $pageQuery, 'loop', 'search' ) ?>
<div class="navigation" style="text-align:right;"><p><?php posts_nav_link(); ?></p></div>
<?php wp_reset_query(); ?>
<?php
// if ($numcharts == 0) {
// } elseif ($numcharts > 0) {
if ( true || $numcharts = true ) {
// $WP_Query = new WP_Query("s=$searchterm&posts_per_page=-1&post_type=post,chart");
// $wp_query = $chartQuery;
get_loop_template( $chartQuery, 'loop', 'charts-new' );
?>
<!-- <h3 class="search"><?php echo $numcharts; ?> chart<?php if ($numpages!=1) echo 's'; ?> found.</h3> -->
<!-- <h3 class="search"><?php echo $numCharts; ?> chart<?php if ($numpages!=1) echo 's'; ?> found.</h3> -->
<?php // get_template_part( 'loop', 'charts-new' ) ?>
<?php } ?>
</div>
</div><!-- /.intro???????-->
<?php get_sidebar() ?>
<?php get_footer(); ?>