Advertisement
Beee

category template (sk8whls)

Sep 21st, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1. <?php
  2.     get_template_part('templates/page', 'header');
  3.  
  4.     wp_reset_query();
  5.  
  6.     // Custom Query
  7.     $cur_cat_id     = get_cat_id(single_cat_title("", false));
  8.     $meta_key           =   'diameter';
  9.     $orderby            = 'title meta_value_num';
  10.     $order              = 'asc';
  11.     $paged              = ( get_query_var('page') ) ? get_query_var('page') : 1;
  12.  
  13.     if ( current_user_can('manage_options') ) {
  14.         $numberposts    = '30';
  15.         // $poststatus  = array('publish','future');
  16.         $poststatus     = 'publish';
  17.     } else {
  18.         $numberposts    = '30';
  19.         $poststatus     = 'publish';
  20.     }
  21.    
  22.     $catargs = array(
  23.         'post_type'             => 'wheels',
  24.         'cat'                           =>  $cur_cat_id,
  25.     'post_status'       =>  $poststatus,
  26.     'meta_key'              =>  $meta_key,
  27.         'orderby'                   =>  $orderby,
  28.         'order'                     =>  $order,
  29.         'posts_per_page'    =>  $numberposts,
  30.         'paged'                     =>  $paged
  31.     );
  32.   // $temp = $wp_query;  // assign orginal query to temp variable for later use  
  33.   // $wp_query = null;
  34.     $wp_query = new WP_Query($catargs);
  35.     $countquery = $wp_query->found_posts;
  36.     if ( $countquery > 1 ) {
  37.         $numberwheels = 'wheels';
  38.     } else {
  39.         $numberwheels = 'wheel';
  40.     }
  41.  
  42.     echo "\n";
  43.     echo '<section id="wheellist">';
  44.     echo "\n";
  45.  
  46.         echo '<p>Result: We have '.$countquery.' ' . $numberwheels . ' for this brand in our database, ordered by wheel name (then by diameter).</p>';
  47.  
  48.     $siteurl = home_url();
  49.         if ( $countquery > 30 ) {
  50.             echo "<p class=\"notex\">Please note pagination doesn't work properly (yet) for brands with more than 30 wheels, so you only see max 30 results. Please use the filter on the <a href=\"'.$siteurl.'\">frontpage</a> to show all wheels for this brand.</p>";          
  51.         }
  52.  
  53.         get_template_part('templates/loop', 'wheellist');
  54.  
  55.         // echo '<div class="footerbanner"><img src="http://placehold.it/600x100.jpg" alt="" /></div>';
  56.            
  57.     echo "\n</section>\n";
  58.     wp_reset_query();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement