Advertisement
jdhall1972

Sort

Nov 18th, 2012
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.08 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: All Properties
  4. */
  5. ?>
  6. <?php get_header(); ?>
  7.  
  8. <div class="container fix">
  9.        
  10.     <div id="page-title">
  11.         <h1><?php echo wpb_page_title(); ?></h1>
  12.     </div><!--/page-title-->
  13.    
  14.     <div id="content">
  15.         <article id="entry-<?php the_ID(); ?>" <?php post_class('entry fix'); ?>>
  16.             <div class="pad">
  17.                 <div class="text">
  18.  
  19. <form method="post" id="order">
  20.   <select name="sort" onchange='this.form.submit()'>
  21.     <option value="">Sort by</option>  
  22.     <option value="zip">Sort by Zip Code</option>
  23.     <option value="type">Sort by Property Type</option>
  24.   </select>
  25. </form>
  26.  
  27. <?php
  28. if(isset($_REQUEST['sort'])) {
  29. if($_REQUEST['sort'] == 'zip' )
  30.     $order = array(
  31.     'cat' => 30,
  32.     'meta_key' => 'zip_code',
  33.     'orderby' => 'meta_value',
  34.     'order' => 'ASC',
  35.     'paged' => $paged
  36. );
  37.  
  38. else if($_REQUEST['sort'] == 'type' )
  39.     $order = array(
  40.     'cat' => 30,
  41.     'meta_key' => 'property_type',
  42.     'orderby' => 'meta_value',
  43.     'order' => 'ASC',
  44.     'paged' => $paged
  45. );
  46.  
  47. }
  48.  
  49. else
  50.     $order = array(
  51.     'cat' => 30,
  52.     'orderby' => 'title',
  53.     'order' => 'ASC',
  54.     'paged' => $paged
  55. );
  56.  
  57. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  58.  
  59. $my_query = new WP_Query($order);
  60.  
  61. while($my_query->have_posts()) : $my_query->the_post();
  62.  
  63. ?>
  64.  
  65.                     <div id="listing">
  66.                         <div class="name"><a href="<?php the_permalink(); ?>" title="<?php the_field('property_name'); ?>"><?php the_field('property_name'); ?></a></div>
  67.  
  68.                         <div class="left">
  69.                         <?php $image = get_field('gallery'); if ($image) { echo '<img src="'.$image[0]['url'].'" />'; } ?>
  70.                         </div>
  71.  
  72.                         <div class="right">
  73.                             <div class="address"><?php the_field('street_address'); ?><br /><?php the_field('city'); ?>, <?php the_field('state'); ?> <?php the_field('zip_code'); ?></div>
  74.                             <div class="details"><a href="<?php the_permalink(); ?>" title="<?php the_field('property_name'); ?>">View Details</a></div>
  75.                             <div class="clear"></div>                      
  76.  
  77.                             <?php if(get_field('listing_type') == "For Sale"): ?>
  78.                             <div class="four-col"><strong>Listing Type</strong></div>
  79.                             <div class="four-col"><strong>Property Type</strong></div>
  80.                             <?php if(get_field('property_type') == "Land"): ?>
  81.                             <div class="four-col"><strong>Lot Size</strong></div>
  82.                             <?php else: ?>
  83.                             <div class="four-col"><strong>Building Size</strong></div>
  84.                             <?php endif; ?>
  85.                             <div class="four-col"><strong>Price</strong></div>
  86.                             <div class="clear"></div>
  87.  
  88.                             <div class="line"></div>
  89.        
  90.                             <div class="four-col"><?php the_field('listing_type'); ?></div>
  91.                             <div class="four-col"><?php the_field('property_type'); ?></div>
  92.                             <?php if(get_field('property_type') == "Land"): ?>
  93.                             <div class="four-col">
  94.                             <?php the_field('total_lot_size'); ?>
  95.                             </div>
  96.                             <?php else: ?>
  97.                             <div class="four-col">
  98.                             <?php the_field('total_building_size'); ?> SF
  99.                             </div>
  100.                             <?php endif; ?>
  101.                             <div class="four-col">$<?php the_field('price'); ?></div>
  102.                             <div class="clear"></div>
  103.                             <?php else: ?>
  104.                             <?php endif; ?>
  105.  
  106.                             <?php if(get_field('listing_type') == "For Lease"): ?>
  107.                             <div class="four-col"><strong>Listing Type</strong></div>
  108.                             <div class="four-col"><strong>Property Type</strong></div>
  109.                             <div class="four-col"><strong>Avail SF</strong></div>
  110.                             <div class="four-col"><strong>Rental Rate</strong></div>
  111.                             <div class="clear"></div>
  112.  
  113.                             <div class="line"></div>
  114.  
  115.                             <div class="four-col"><?php the_field('listing_type'); ?></div>
  116.                             <div class="four-col"><?php the_field('property_type'); ?></div>
  117.                             <div class="four-col"><?php the_field('total_space_available'); ?> SF</div>
  118.                             <div class="four-col">$<?php the_field('rental_rate'); ?>/SF</div>
  119.                             <div class="clear"></div>
  120.                             <?php else: ?>
  121.                             <?php endif; ?>
  122.  
  123.                         </div>
  124.                         <div class="clear"></div>
  125.  
  126.                     </div>
  127.  
  128. <?php endwhile; ?>
  129.  
  130. <?php wp_pagenavi( array( 'query' => $my_query ) ); wp_reset_postdata(); ?>
  131.  
  132.                 </div>
  133.             </div>
  134.         </article>
  135.     </div>     
  136. </div><!--/container-->
  137.  
  138. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement