Answer the question
In order to leave comments, you need to log in
How to display all categories of current posts?
I have a search. And wp query filters posts by search result.
$posts = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 9999,
's' => $_GET["s"],
)
);
$catArray = array(
'taxonomy' => 'post_category',
'type' => 'post',
'hide_empty' => true,
);
$categories = get_categories( $catArray );
foreach ( $categories as $cat ) {
$catLink = get_category_link($cat->cat_ID);
$active = '';
if ($catLink == $pagelink) {
$active = ' active';
}
?>
<li>
<a class="category<?php echo $active; ?>" href="<?php echo get_category_link($cat->cat_ID); ?>">
<span class="radio-el"></span>
<span class="title"><?php echo $cat->name ?></span>
<span class="count"><?php echo $cat->count; ?></span>
</a>
</li>
<?php } ?>
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