I have the following function that returns the tags of the current post:

<?php the_tags( '<ul> <li>', '</ li> <li>', '</ li> </ ul>' ); ?>


enter image description here

Is there any way to split the result into 2 columns?

Would return something like this:

enter image description here

Any hint is welcome. Thank you friends!

  • 1
    you can also check out the multi columns in CSS3, but that might not cover all browsers ;-) – birgire May 7 '13 at 17:47

Use get_the_tags instead of the_tags to grab an array of tags, and array_chunk to split it. You will then need to build a loop to display the tags.

$tags = get_the_tags(); 
if (!empty($tags)) {
  $tags = array_chunk($tags,ceil(count($tags)/2),true);
  foreach($tags as $v) {
    echo '<ul>';
    foreach ($v as $tag) {
      echo '<li><a href="'.get_tag_link($tag->term_id).'">' . $tag->name . '</a></li>'; 
    echo '</ul>';



  • Perfect @s_ha_dum! Now we need to find a way to use CSS3 to position the first <ul> left. – BobGCA May 7 '13 at 18:25
  • All you should need to do is float the <ul>s. – s_ha_dum May 7 '13 at 18:27
  • Oops, that's what I meant, lol. – BobGCA May 7 '13 at 18:30
  • I thought I should just add float in a <ul>. But really worked (at least in Chrome). – BobGCA May 7 '13 at 18:43

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.