B
B
Boris Belov2018-04-18 15:27:10
PHP
Boris Belov, 2018-04-18 15:27:10

How to wrap a DIV after 6 posts?

Hello everyone
5ad739563d4ee662694897.pngThe 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

2 answer(s)
D
Dmitry Dart, 2018-04-18
@iborisbelov

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>';
}

E
E, 2018-04-18
@aylo

what did you say there? right now another one will come and post how to wrap 8 posts in divs
how to wrap divs every 3 posts the
idea is the same

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question