Support

Account

Home Forums General Issues Help With Taxonomies Reply To: Help With Taxonomies

  • Hi @jeremybdavis,

    Thanks for the post.

    To show the attached product, you can have the following loop:

    <?php 
    
    $terms = get_field('attached_product');
    
    if( $terms ): ?>
    
    	<ul>
    
    	<?php foreach( $terms as $term ): ?>
    
    		<h2><?php echo $term->name; ?></h2>
    		
    
    	<?php endforeach; ?>
    
    	</ul>
    
    <?php endif; ?>

    As for the posts in a particular taxonomy you will need to create a loop to get the posts like so:

    $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'attached_product',
    			'field'    => 'slug',
    			'terms'    => 'product',
    		),
    	),
    );
    $query = new WP_Query( $args );