Support

Account

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,
    		)
    	)
    );