Support » Plugins » Can't display results with meta_query

  • I created a field with the Adv Custom Fields plugin which allows the user to select which section the page is under (like categories). On each page I’d like to display a sidebar which shows a list of pages with the same section. I attempted to use meta_query and I don’t get any results. I would also like to display the parent page first if there’s a way to do it. Here’s my query:

    <ul class="test-menu">
       $section = get_field('section'); 
       $args = array(
          'meta_query' => array(
                'key'    => 'section',
                'value'  => $section
       $loop = new WP_Query( $args );
       while ( $loop->have_posts() ) : $loop->the_post();
          <li><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
       <?php endwhile; ?>
       <?php wp_reset_query(); ?>
  • The topic ‘Can't display results with meta_query’ is closed to new replies.