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 http://codex.wordpress.org/Class_Reference/WP_Query
for using a relationship field Eliot has a tutorial here http://www.advancedcustomfields.com/resources/querying-relationship-fields/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.