Get all tags from current category WordPress

Viewed 21

I have this code but I need to display all tags of current category (I'm into category.php).

For exampe: Category "example" have 3 post with 5 tags, belowe I need to display 5 tags with link

<?php
    global $post;
    $args = array(
    'post_type' => 'post',
    'cat' => get_query_var('cat') 
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) { 
    while ( $loop->have_posts() ) : $loop->the_post();
?>

<div class="block_singlular_loop">
    <?php
    $posttags = get_the_tags();
    if ($posttags) {
        foreach($posttags as $tag) {
        echo $tag->name . ' ';
        }
    }
?>
</div>

<?php
    endwhile;
} else {
    echo __( 'No post found.' );
}
wp_reset_postdata();
?>

0 Answers
Related