Skip to content

Instantly share code, notes, and snippets.

@sminso
Created December 19, 2016 22:39
Show Gist options
  • Save sminso/54976099aa1bfd3dce77cac5562b8dd5 to your computer and use it in GitHub Desktop.
Save sminso/54976099aa1bfd3dce77cac5562b8dd5 to your computer and use it in GitHub Desktop.
<?php
remove_action( 'genesis_loop', 'genesis_do_loop');
add_action( 'genesis_loop', 'lofts_floor_plan_loop' );
function my_facetwp_is_main_query( $is_main_query, $query ) {
if ( isset( $query->query_vars['facetwp'] ) ) {
$is_main_query = true;
}
return $is_main_query;
}
add_filter( 'facetwp_is_main_query', 'my_facetwp_is_main_query', 10, 2 );
//* 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">';
$args = array(
'post_type' => 'floor-plans',
'facetwp' => true,
'meta_key' => 'availability',
'meta_value' => 'yes',
);
$query = new WP_Query( $args );
if( $query->have_posts() ): while( $query->have_posts() ) : $query->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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment