Home › Forums › General Issues › Query by Post_Object › Reply To: Query by Post_Object
<?php
$post_id = get_the_ID();
$args = array(
'post_type' => 'post',
'posts_per_page'=> -1,
'meta_query' => array(
array(
'key' => 'attraction_in',
'value' => $post_id,
'compare' => 'IN'
)
)
);
// query
$wp_query = new WP_Query( $args );
if ($wp_query->have_posts() ) :
echo '<div class="single-destination-list-items">';
echo '<h3>Top attractions in '.get_the_title( $post_id ).'</h3>';
echo '<ul>';
while( $wp_query->have_posts() ) { $wp_query->the_post();
?>
<li>
<a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $page->ID, 'tours' ); ?></a>
<div class="items-right">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</div>
</li>
<?php
}
echo '</ul>';
echo '</div>';
endif;
?>
I did use this code, but not working fine, please help me .
Thanks
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.