Skip to content

Instantly share code, notes, and snippets.

@hiiightower
Forked from jainnidhi/acf-relation
Created January 30, 2018 01:50
Show Gist options
  • Save hiiightower/160ff20a7d1ed7b759831c958274b901 to your computer and use it in GitHub Desktop.
Save hiiightower/160ff20a7d1ed7b759831c958274b901 to your computer and use it in GitHub Desktop.
reverse lookup acf relationship field and passing variable in template part
<?php
$auctionend='';
$args = array(
'post_type' => 'auction',
'meta_query' => array(
array(
'key' => 'connect_property_single',
'value' => '"'. get_the_ID() .'"',
'compare' => 'LIKE'
)
)
);
$loop = new WP_Query($args);
if($loop->have_posts()) :
while($loop->have_posts()) : $loop->the_post();
$auctionend = get_field( 'auction_end' );
endwhile;
endif;
wp_reset_query();
?>
<section class="container-fluid" id="section7">
<div class="container">
<div class="row">
<?php set_query_var( 'auctionend', $auctionend ); ?>
<?php get_template_part( 'content/content', 'property' ); ?>
</div>
</div>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment