0

I have a custom terms loop, that gets category images and links.

<?php 
foreach (get_terms( 'razotajs', 'orderby=count&order=DESC&hide_empty=0&parent=0' ) as $cat) : ?>
    <a href="<?php echo get_term_link($cat->slug, 'razotajs'); ?>" title="<?php echo $cat->name; ?>">
        <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" alt="<?php echo $cat->name; ?>" />
    </a>
<?php endforeach; ?>

I need to wrap each 6 categories a in logo_sets div. I use Circle2 slider plugin with html data attributes, if i use JQ split and wrap function, slider dont work. Is there a way to add wrap in loop?

  • Can you give an example of the desired HTML output? – birgire Apr 27 '16 at 10:38
0

Here is solution, split in arrays:

<?php
            foreach (array_chunk(get_terms( 'razotajs', 'orderby=count&order=DESC&hide_empty=0&parent=0' ), 6, true) as $array)
            {
                echo '<div class="logo_sets">';
                foreach($array as $cat)
                { ?>
                     <a href="<?php echo get_term_link($cat->slug, 'razotajs'); ?>" title="<?php echo $cat->name; ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" alt="<?php echo $cat->name; ?>" /></a>
                <?php }
                echo '</div>';
            }
            ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.