Support

Account

Home Forums General Issues Deeply nested post types Reply To: Deeply nested post types

  • 
    <?php
    $args = array(
      'post_type' => 'county',
      'posts_per_page' => -1,
      'meta_query' => array(
        'key' => 'state',
        'value' => $post->ID,
      ),
    );
    $query = new WP_Query($args);
    
    // you need to refer to the new query object you created above
    if($query->have_posts()) : ?>
    <ul>
    <?php while($query->have_posts()) : $query->the_post(); ?>
      <li><?php the_title(); ?></li>
    <?php endwhile; ?>
    </ul>
    <?php endif; ?>