Support

Account

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