Home › Forums › Front-end Issues › Sorting / Querying from One Custom Post › Reply To: Sorting / Querying from One Custom Post
Hi @okozarsky
So I think I get what you’re after. My question was to verify the setup you have.
What you want to do is query all cpt shows based on their subfield values of the ID for the current volunteer post you’re at.
Take a look at example 4 here: http://www.advancedcustomfields.com/resources/query-posts-custom-fields/
You want your arguments to be something like:
//Get the volunteer posts ID
$post_id = get_the_ID();
//Fetching all shows the volunteer was actor in
$args = array(
'numberposts' => -1,
'post_type' => 'show',
'meta_query' => array(
array(
'key' => 'cast_%_actor',
'compare' => '=',
'value' => post_id,
)
)
);
//Fetching all shows the volunteer was crew in
$args = array(
'numberposts' => -1,
'post_type' => 'show',
'meta_query' => array(
array(
'key' => 'crew_%_crew_person_name',
'compare' => '=',
'value' => post_id,
)
)
);
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.