Display post in different tags (classic post by tags)

<ul>
<?php
$tags = get_tags();
$count = count($tags);
if ($count > 0) {
foreach ( $tags as $tag ) {
echo '<a href="' . get_tag_link ($tag->term_id) . '" rel="tag">' . $tag->name . ' </a>';
?>

<ul class="products-cus">
        <?php $loop = new WP_Query(array('tag' => $tag->name,'posts_per_page' => 6));
            while ( $loop->have_posts() ) : $loop->the_post(); ?>

                <a href="<?php the_permalink() ?>">
                <li class="group-cus">
                <h5 ><?php the_title(); ?></h5>
                </li>
</a>

                <?php endwhile; ?>
        </ul>



<?php
}
}?>
</ul>

Post a Comment