Forked from fseonline/keystones-featured-property.php
Last active
January 2, 2019 13:42
-
-
Save propertyhive/5680b2686b24e2eab58dde6f4f63ba06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'property', | |
'ignore_sticky_posts' => 1, | |
'posts_per_page' => 1, // change to show more than 1 | |
'orderby' => 'rand', | |
'order' => 'desc', | |
); | |
$meta_query = array( | |
array( | |
'key' => '_on_market', | |
'value' => 'yes', | |
), | |
array( | |
'key' => '_featured', | |
'value' => 'yes' | |
) | |
); | |
// Use if only wanting to show properties from one department (i.e. onle sales or only lettings) | |
/*$meta_query[] = array( | |
'key' => '_department', | |
'value' => 'residential-sales', | |
'compare' => '=' | |
);*/ | |
$args['meta_query'] = $meta_query; | |
$properties = new WP_Query( $args ); | |
if ( $properties->have_posts() ) | |
{ | |
while ( $properties->have_posts() ) | |
{ | |
$properties->the_post(); | |
$property = new PH_Property(get_the_ID()); | |
?> | |
<section class="featured-property section-featured-property"> | |
<div class="row no-gutters"> | |
<div class="col-12 col-lg-6"> | |
<a href="<?php echo get_permalink(); ?>" target="_blank"> | |
<div class="featured-property__video"> | |
<style media="screen"> | |
.featured-property__video { | |
background-image: url('<?php echo $property->get_main_photo_src('large'); ?>'); | |
} | |
</style> | |
</div> | |
</a> | |
</div> | |
<div class="col-12 col-lg-6"> | |
<div class="featured-property__content ml-auto mr-auto ml-lg-0"> | |
<h2 class="featured-property__content__heading">Featured Property</h2> | |
<h3 class="featured-property__content__property-title"><?php echo get_the_title(); ?></h3> | |
<div class="featured-property__content__price"> | |
<span><?php echo $property->get_formatted_price(); ?></span> | |
</div> | |
<?php if( $property->post_excerpt !== '' ): ?> | |
<p class="featured-property__content__description"><?php echo limit_words( $property->post_excerpt, 26 ) . '…'; ?></p> | |
<?php endif; ?> | |
<a class="btn btn--primary-1 mt-3" href="<?php echo get_permalink(); ?>" target="_blank">View Property</a> | |
</div> | |
</div> | |
</div> | |
</section> | |
<?php | |
} // end while | |
} // end if | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment