<?php
/*
Template Name: All Properties
*/
?>
<?php get_header(); ?>
<div class="container fix">
<div id="page-title">
<h1><?php echo wpb_page_title(); ?></h1>
</div><!--/page-title-->
<div id="content">
<article id="entry-<?php the_ID(); ?>" <?php post_class('entry fix'); ?>>
<div class="pad">
<div class="text">
<form method="post" id="order">
<select name="sort" onchange='this.form.submit()'>
<option value="">Sort by</option>
<option value="zip">Sort by Zip Code</option>
<option value="type">Sort by Property Type</option>
</select>
</form>
<?php
if(isset($_REQUEST['sort'])) {
if($_REQUEST['sort'] == 'zip' )
$order = array(
'cat' => 30,
'meta_key' => 'zip_code',
'orderby' => 'meta_value',
'order' => 'ASC',
'paged' => $paged
);
else if($_REQUEST['sort'] == 'type' )
$order = array(
'cat' => 30,
'meta_key' => 'property_type',
'orderby' => 'meta_value',
'order' => 'ASC',
'paged' => $paged
);
}
else
$order = array(
'cat' => 30,
'orderby' => 'title',
'order' => 'ASC',
'paged' => $paged
);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$my_query = new WP_Query($order);
while($my_query->have_posts()) : $my_query->the_post();
?>
<div id="listing">
<div class="name"><a href="<?php the_permalink(); ?>" title="<?php the_field('property_name'); ?>"><?php the_field('property_name'); ?></a></div>
<div class="left">
<?php $image = get_field('gallery'); if ($image) { echo '<img src="'.$image[0]['url'].'" />'; } ?>
</div>
<div class="right">
<div class="address"><?php the_field('street_address'); ?><br /><?php the_field('city'); ?>, <?php the_field('state'); ?> <?php the_field('zip_code'); ?></div>
<div class="details"><a href="<?php the_permalink(); ?>" title="<?php the_field('property_name'); ?>">View Details</a></div>
<div class="clear"></div>
<?php if(get_field('listing_type') == "For Sale"): ?>
<div class="four-col"><strong>Listing Type</strong></div>
<div class="four-col"><strong>Property Type</strong></div>
<?php if(get_field('property_type') == "Land"): ?>
<div class="four-col"><strong>Lot Size</strong></div>
<?php else: ?>
<div class="four-col"><strong>Building Size</strong></div>
<?php endif; ?>
<div class="four-col"><strong>Price</strong></div>
<div class="clear"></div>
<div class="line"></div>
<div class="four-col"><?php the_field('listing_type'); ?></div>
<div class="four-col"><?php the_field('property_type'); ?></div>
<?php if(get_field('property_type') == "Land"): ?>
<div class="four-col">
<?php the_field('total_lot_size'); ?>
</div>
<?php else: ?>
<div class="four-col">
<?php the_field('total_building_size'); ?> SF
</div>
<?php endif; ?>
<div class="four-col">$<?php the_field('price'); ?></div>
<div class="clear"></div>
<?php else: ?>
<?php endif; ?>
<?php if(get_field('listing_type') == "For Lease"): ?>
<div class="four-col"><strong>Listing Type</strong></div>
<div class="four-col"><strong>Property Type</strong></div>
<div class="four-col"><strong>Avail SF</strong></div>
<div class="four-col"><strong>Rental Rate</strong></div>
<div class="clear"></div>
<div class="line"></div>
<div class="four-col"><?php the_field('listing_type'); ?></div>
<div class="four-col"><?php the_field('property_type'); ?></div>
<div class="four-col"><?php the_field('total_space_available'); ?> SF</div>
<div class="four-col">$<?php the_field('rental_rate'); ?>/SF</div>
<div class="clear"></div>
<?php else: ?>
<?php endif; ?>
</div>
<div class="clear"></div>
</div>
<?php endwhile; ?>
<?php wp_pagenavi( array( 'query' => $my_query ) ); wp_reset_postdata(); ?>
</div>
</div>
</article>
</div>
</div><!--/container-->
<?php get_footer(); ?>