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

  • That would most definitely be easier if you use a Post Object field rather than a relationship.

    With a post object you’d need to do a query, for example on the state page, to get all the counties

    // assuming this is on the single state template
    // $post->ID represents the id for the state post
    // this only works with a Post Object field
    $args = array(
      'post_type' => 'county',
      'posts_per_page' => -1,
      'meta_query' => array(
        'key' => 'state',
        'value' => $post-ID,
    $query = new WP_Query($args);

    see WP_Query

    for using a relationship field Eliot has a tutorial here