Support

Account

Home Forums Front-end Issues query based on current page Reply To: query based on current page

  • So either there is none of there is an error in the get_posts() arguments. After looking at the codex for get_posts I think it the wrong function to use in this case. Go back to WP_Query

    
    $args = array(
        'post_type'  => 'event',
        'meta_query' => array(
            array(
                'key' => 'business_name',
                'value' => '"'.get_the_ID().'"',
                'compare' => 'LIKE'
            )		
        )
     );
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            echo '<p>',get_the_title(),'</p>';
        }
    }
    wp_reset_postdata();