Answer the question
In order to leave comments, you need to log in
The condition that you are in the post terma?
I have a list of terms in single-services.php page
<?php
$all_terms = get_terms( 'services_tax', array( 'hide_empty' => 0, 'childless' => false,
'parent' => 0, ) );
foreach ( $all_terms as $term ) {
$term_link = get_term_link($term);
$class = ( is_tax('services_tax', $term->slug) ) ? 'current' : '';
echo "<div class='acc-tags'>";
echo "<h6 class='red-text $class'><a href='$term_link'>$term->name</a></h6>";
echo "<div class='under-text'>";
echo "<ul class='under-list'>";
$query = new WP_Query( array(
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'services_tax',
'field' => 'slug',
'terms' => $term->slug,
'include_children' => false,
)
)
));
while ( $query->have_posts() ) {
$query->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
}
echo "</ul>";
echo "</div>";
echo "</div>";
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question