sorry for my noob code but it feels close to what I am trying to achieve. I need help on displaying the taxonomy values inside the archive post loop. I have a custom post type called "plays" and there are custom taxonomies tied to it called "leagues" and "systems". There are multiple kinds of ‘leagues’ and ‘systems’ but I need to show only the ones that are in each post. Here is the code:
<?php if( have_posts() ): while( have_posts() ): the_post();?>
<div class="row pick-row">
<div class="col-md-4 valign">
<div class="row">
<div class="col-md-6 col-6 pb-4">
<p class="pick-date"><b><?php the_field('date');?></b></p>
<h2>
<?php the_title();?>
</h2>
</div>
<div class="col-md-6 col-6 pb-4">
<div class="model-league">
<p>
<b>Model</b>
</p>
<?php
// Get the taxonomy's terms
$terms = get_terms(
array(
'taxonomy' => 'system',
'hide_empty' => true,
)
);
// Check if any term exists
if ( ! empty( $terms ) && is_array( $terms ) ) {
// Run a loop and print them all
foreach ( $terms as $term ) { ?>
<a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
<?php echo $term->name; ?>
</a><?php
}
}
?>
<p>
<b>League</b>
</p>
<?php
// Get the taxonomy's terms
$terms = get_terms(
array(
'taxonomy' => 'leagues',
'hide_empty' => true,
)
);
// Check if any term exists
if ( ! empty( $terms ) && is_array( $terms ) ) {
// Run a loop and print them all
foreach ( $terms as $term ) { ?>
<a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
<?php echo $term->name; ?>
</a><?php
}
}
?>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row picks-details">
<div class="col-md-3 col-6 pb-4">
<h2>
Selection
</h2>
<span>
<?php the_field('selection');?>
</span>
</div>
<div class="col-md-3 col-6 pb-4">
<h2>
Odds
</h2>
<span>
<?php the_field('odds');?>
</span>
</div>
<div class="col-md-3 col-6 pb-4">
<h2>
Stake
</h2>
<span>
<?php the_field('stake');?>
</span>
</div>
<div class="col-md-3 col-6 pb-4">
<h2>
Units
</h2>
<span>
<?php the_field('units');?>
</span>
</div>
</div>
</div>
<div class="col-md-2 pb-4 valign text-center text-md-right">
<a class="btn btn-main" href="<?php the_permalink();?>"">
Details
</a>
</div>
<div class="col-md-12">
<hr>
</div>
</div>
<?php endwhile; else: endif;?>