mgibbs189

{{gist file=”archive-floor-plans.php” lang=”php”}}
<?php
remove_action( ‘genesis_loop’, ‘genesis_do_loop’);
add_action( ‘genesis_loop’, ‘lofts_floor_plan_loop’ );

//* Add filtering sidebar
add_action( ‘genesis_before_content’, ‘floorplan_filters’ );

function floorplan_filters() {

echo ‘<div class=”floorplan-filters”>’;

echo ‘<div class=”one-third first”>’;
echo ‘Bedrooms’;
echo facetwp_display( ‘facet’, ‘bedrooms’ );
echo ‘</div>’;

echo ‘<div class=”one-third”>’;
echo ‘Bathrooms’;
echo facetwp_display( ‘facet’, ‘bathrooms’ );
echo ‘</div>’;

echo ‘<div class=”one-third”>’;
echo ‘Price Range’;
echo facetwp_display( ‘facet’, ‘price’ );
echo ‘</div>’;

//echo ‘Available?’;
//echo facetwp_display( ‘facet’, ‘availability’ );

echo ‘</div>’;

}

function lofts_floor_plan_loop() {

echo ‘<div class=”facetwp-template”>’;

if( have_posts() ): while( have_posts() ) : the_post();

echo ‘<div class=”floor-plans-entry clearfix”>’;

?>
<div class=”fp-left”>
<?php echo ‘<h2 class=”entry-title”><a href=”‘ . get_permalink() . ‘”>’ . get_the_title() . ‘</a></h2>’; ?>

<span><strong>Price:</strong> <?php the_field(‘price’); ?></span>
<span><strong>Bedrooms:</strong> <?php the_field(‘bedrooms’); ?></span>
<span><strong>Bathrooms:</strong> <?php the_field(‘bathrooms’); ?></span>
<span><strong>Sqft:</strong> <?php the_field(‘sqft’); ?></span>

<a href=”<?php echo get_permalink(); ?>” class=”button”>Learn More</a>

</div>

<div class=”fp-right”>

<?php // Disply first image from gallery and link to listing
$images = get_field(‘images’);
if( $images ):
$image_1 = $images[0];
?>
<a href=”<?php the_permalink(); ?>”>
<img src=”<?php echo $images[0][‘sizes’][‘medium’]; ?>” alt=”<?php echo $image[‘alt’]; ?>” />
</a>
<?php endif; ?>

</div>
<?php

echo ‘</div>’;

endwhile; endif;
}
echo ‘</div>’;

genesis();

{{/gist}}{{gist file=”functions.php” lang=”php”}}
<?php

function fwp_archive_per_page( $query ) {
if ( in_category( ‘floor-plans’ ) ) {
$query->set( ‘post_type’, ‘floor-plans’ );
$query->set( ‘meta_key’, ‘availability’ );
$query->set( ‘meta_value’, ‘yes’ );
}
}
add_filter( ‘pre_get_posts’, ‘fwp_archive_per_page’ );

{{/gist}}