jeudi 26 février 2015

Displaying Custom taxonomy term on page made up of posts

I'm trying to display a taxonomy term for each post on this page by using



<?php foreach(get_the_terms($wp_query->post->ID, 'stock') as $term) echo $term->slug; ?>


I've used this before in body classes so i can style pages better but i'm not sure why it's not working here...


can anyone help please?



<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php $catquery = new WP_Query( 'cat=10&posts_per_page=10' ); while($catquery->have_posts()) : $catquery->the_post(); ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<div class="container">
<a data-toggle="collapse" class="collapsed" data-parent="#accordion" href="#collapse<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<h4 class="panel-title">
<?php the_title(); ?><div class="stock-level"> <?php foreach(get_the_terms($wp_query->post->ID, 'stock') as $term) echo $term->slug; ?></div>
</h4></a>
</div>
</div>
<div id="collapse<?php echo $i; ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<div class="container">
<div class="row">

<div class="col-xs-12 col-sm-7 col-md-7 col-lg-7 recycled-image">
<?php echo the_post_thumbnail(); ?>
</div>

<div class="col-xs-12 col-sm-5 col-md-5 col-lg-5">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
</div>

</div>
</div>
</div>
</div>

</div>
<?php $i++; endwhile; ?>

Aucun commentaire:

Enregistrer un commentaire