Home Forums General Issues Taxonomy Relationship Reply To: Taxonomy Relationship

  • Hi @kurdt_the_goat

    Thanks for the follow up. I’ll add in the taxonomy field docs soon, but for the time being, you can see the data available with some simple debugging:

    $taxonomies = get_field('field_name');
    echo '<pre>';
    	print_r( $taxonomies );
    echo '</pre>';

    The above example shows how you can load the taxonomy field values (when viewing a speaker post), and then simple output them visually so you can see the available data.

    To then get all ‘related’ speakers from that year, you can query the posts like so:

    $taxonomies = get_field('field_name');
    // args
    $args = array(
    	'numberposts' => -1,
    	'post_type' => 'speaker',
    	'tax_query' => array(
    			'taxonomy' => 'year',
    			'field' => 'slug',
    			'terms' => array()
    if( $taxonomies )
    	foreach( $taxonomies as $term )
    		$args['tax_query']['terms'][] = $term->slug;
    // get results
    $the_query = new WP_Query( $args );

    Please note that the above is not tested, and I am assuming that the variable $term has a property called slug.

    Please debug the code to make sure the data is correct.

    Hope that helps.