Advertisement
mwelfare

WP Search.php

Sep 9th, 2011
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <div id="main">
  2.         <section>
  3.             <header>
  4.                 <hgroup>
  5.                     <h1 class="searchh1"><?php printf( __( 'Your search <span>&quot;%s&quot;</span> returned the following results', 'twentyeleven' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
  6.                 </hgroup>
  7.             </header>
  8.            
  9.             <?php
  10.                     $page_query = new WP_Query("s=$s&paged=$paged&showposts=5&post_type=page"); //$page_query->query_vars['post_type']='page';//query_posts("s=$s&paged=$paged&cat=-1,-11,-101");
  11.                     $post_query = new WP_Query("s=$s&paged=$paged&showposts=5&post_type=post"); //$post_query->query_vars['post_type']='post';//query_posts("s=$s&paged=$paged&cat=-1,-11,-101");
  12.             ?>
  13.                
  14.             <?php if($post_query->have_posts()) :
  15.                 if(!$page_query->have_posts()) {$wp_query= null; $wp_query = clone $post_query;}
  16.             ?>
  17.                    
  18.             <h2 class="pagetitle">Post Search Results</h2>
  19.        
  20.             <table class="search">
  21.                 <tbody>
  22.                     <tr>
  23.                     <th>Book Name</th>
  24.                     <th>Author(s)</th>
  25.                     <th>Year Published</th>
  26.                     <th>Edition</th>
  27.                     <th>Publisher</th>
  28.                     <th></th>
  29.                     </tr>
  30.                    
  31.             <?php while ($post_query->have_posts()) : $post_query->the_post(); ?>
  32.                    
  33.                     <?php
  34.  
  35.                         get_template_part( 'content', 'searchbook' );
  36.                     ?>
  37.                    
  38.         <?php endwhile; ?>
  39.        
  40.                 </tbody>
  41.             </table>
  42.    
  43.         <?php endif;?>
  44.        
  45.         <?php if ($page_query->have_posts()) :
  46.         $wp_query= null; $wp_query = clone $page_query;
  47.         ?>
  48.        
  49.         <h2 class="pagetitle">Page Search Results</h2>
  50.  
  51.         <table class="search">
  52.             <tbody>
  53.                 <tr>
  54.                     <th>Module Name</th>
  55.                     <th>Module Code</th>
  56.                     <th>University</th>
  57.                     <th>Module Convenor</th>
  58.                     <th></th>
  59.                 </tr>
  60.    
  61.             <?php while ($page_query->have_posts()) : $page_query->the_post(); ?>
  62.  
  63.                     <?php
  64.  
  65.                         get_template_part( 'content', 'searchmodule' );
  66.                     ?>
  67.  
  68.         <?php endwhile; ?>
  69.        
  70.             </tbody>
  71.         </table>
  72.    
  73.       <?endif; ?>
  74.    
  75.     <?php if (!$page_query->have_posts() && !$post_query->have_posts()) : ?>
  76.    
  77.     <h2 class="center">No results were found. Please try a different search?</h2>
  78.         <?php include (TEMPLATEPATH . '/searchform.php'); ?>
  79.     <?php endif; ?>
  80.  
  81.         </section><!-- #primary -->
  82.             </div><!-- #content -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement