Support

Account

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

  • Thanks for all the help so far. I appreciate it a lot.

    I finally got back to this project and tried your suggestion. I closed the main loop and started this one, but <?php the_title(); ?> is returning the state’s title… not the title of the counties. I might be wrong, but my assumption is that I should be able to use the_title() because this secondary loop is going through the county post type.

    Here’s my code:

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

    Thanks again!