Display post in different categorys (classic post by category)

<ul>
        <?php $terms = get_terms($danhmuc);
        $count = count($terms);
        if ($count > 0) {
        foreach ( $terms as $term ) {
        ?>
        <h2 class="title tag-title"><?php echo $term->name; ?></h2>

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

        <a href="<?php the_permalink() ?>">
                <li class="group">
                <div class="thumbnail">
                        <?php the_post_thumbnail('thumbnail'); ?>
                </div>
                <h5><?php the_title(); ?></h5>
                <p><?php $vnd=get_field('gia');
                echo number_format($vnd,'0',',','.').' '.'đ';
                ?></p>

                </li>
        </a>
                <?php endwhile; ?>
        </ul>



<?php
}
}?>
</ul>

Post a Comment