Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Last active August 12, 2016 14:13
Show Gist options
  • Save propertyhive/fac44243f1c13e1690bbf4e15964daf2 to your computer and use it in GitHub Desktop.
Save propertyhive/fac44243f1c13e1690bbf4e15964daf2 to your computer and use it in GitHub Desktop.
<?php
$args = array(
'post_type' => 'property',
'post_status' => 'publish',
'nopaging' => true,
'orderby' => 'rand',
'meta_query' => array(
array(
'key' => '_on_market',
'value' => 'yes',
),
array(
'key' => '_featured',
'value' => 'yes'
)
)
);
$featured_property_ids = array();
$properties = new WP_Query( $args );
if ( $properties->have_posts() ) :
while ( $properties->have_posts() ) :
$properties->the_post();
$featured_property_ids[] = $post->ID;
endwhile; // end of the loop.
endif;
wp_reset_postdata();
// Not sure on the actual format of the [rev_slider] shortcode, but the key bit is the 'ids' bit.
// Note: apparently you need 0 as the first ID
// Ref: https://www.themepunch.com/faq/use-custom-wp-queries-post-based-sliders/
echo do_shortcode( '[rev_slider alias="tester"]' .
'[gallery ids="0,' . implode( ",", $featured_property_ids ).'"]' .
'[/rev_slider]' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment