Condition for being inside term post?
-
i have list term on single-services.php
<?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>"; } ?>
$class is my condition on taxonomy-services.php and this work i adding class if this current term (like menu)
but i have problem with posts. how i could fix that?
Thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Condition for being inside term post?’ is closed to new replies.