Answer the question
In order to leave comments, you need to log in
How to wrap a DIV after 6 posts?
Hello everyone
The task is this , there are 6 categories that are displayed immediately, when you click on "VIEW ALL" the rest of the categories are displayed below. At the layout stage, everything is done. Faced with the problem of how to attach it to the VP.
There is such a code
<div class="items-wrap">
<? $args = array( 'post_type' => 'news','taxonomy' => 'brands',);
$args_brands = array( 'orderby' => 'name', 'hide_empty' => 1, 'parent' => 0,);
$categories = get_terms('brands', $args_brands ); if($categories){ foreach ($categories as $cat){ ?>
<?php $link_brands = get_term_link($cat->slug, 'brands'); ?>
<a href="<?php echo $link_brands; ?>" class="item">
<div class="img-wrap"><img src="<?php bloginfo('template_url'); ?>/img/news-list-1.png" alt=""></div>
<span><?php echo $cat->name; ?></span></a><? } } ?>
<div class="hidden-items">
вот тут должны быть скрыты остальные посты
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Well, you have the code ... the idea is something like this:
$i = 0;
foreach ($categories as $cat){
$i++;
// ...
if($i % 6 === 0){
echo '</div><div>';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question