Created
September 4, 2012 20:30
-
-
Save ericpedia/3626113 to your computer and use it in GitHub Desktop.
two queries on one page won't work?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template for displaying Search Results pages. | |
* | |
* @package WordPress | |
* @subpackage Twenty_Ten | |
* @since Twenty Ten 1.0 | |
*/ | |
?> | |
<?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; | |
?> | |
<!-- <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> | |
<?php $query = query_posts("s=$searchterm&posts_per_page=3&post_type=page"); ?> | |
<?php // $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> | |
<?php get_template_part( 'loop', 'search' ) ?> | |
<div class="navigation" style="text-align:right;"><p><?php posts_nav_link(); ?></p></div> | |
<?php wp_reset_query(); ?> | |
<?php if ($numcharts == 0) { ?> | |
<?php } elseif ($numcharts > 0) { ?> | |
<?php $query = query_posts("s=$searchterm$query_string&posts_per_page=-1&post_type=post,chart"); ?> | |
<h3 class="search"><?php echo $numcharts; ?> chart<?php if ($numpages!=1) echo 's'; ?> found.</h3> | |
<?php get_template_part( 'loop', 'charts' ) ?> | |
<?php } ?> | |
</div> | |
</div><!-- /.intro???????--> | |
<?php get_sidebar() ?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment