I want to repeat <div>
and <ul>
after every 9th record. But not getting exact result. Please help to sort out the issue.
<div class="col1">
<div class="mylist">
<ul>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
<li class="test1"><a href="#"></a></li>
</ul>
</div>
</div>
<?php
$args1 = array(
'post_type' => 'newser',
'orderby' => 'id',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'service',
'field' => 'id',
'terms' => $term_id
)
)
);
$query1 = new WP_Query( $args1 );
$counter = 1;
while ($query1->have_posts()) : $query1->the_post();
?>
<div class="col1">
<div class="mylist">
<ul>
<li class="test<?php echo $counter; ?>"><a href="#">
<?php the_title(); ?>
</a>
</li>
<?php
if($counter % 9 == 0)
{
echo '</ul></div></div><div class="col-sm-4"><div class="list-part"><ul>';
}
?>
<!-- </ul>
</div>
</div>-->
<?php $counter++; endwhile; ?>
Try this type of code..
Hope this helps.
Hey if you are doing php so below code will work for you:
I think that will be work.
You can write a for-loop that has conditions for the various special conditions, e.g. handling the first element (need the starting
<ul>
), every ninth position (your question), and the last element (need the closing</ul>
).