WordPress.org

Ready to get started?Download WordPress

Forums

Display tag in 4 column (1 post)

  1. agereda
    Member
    Posted 1 year ago #

    Hello i have this code that display 3 Column of tags, but i want to display 4 column but i donĀ“t know how.
    Anybody can help me, i am a newbie in wordpress and Php
    Thanks

    <?php
    $tags = get_tags( array('name__like' => "a", 'order' => 'ASC') );
    $tags_count = count($tags);
    $count = intval( $tags->count );
    $percolumn = ceil($tags_count / 3);
    
    for ($i = 0;$i < $tags_count;$i++):
        if ($i < $percolumn):
        $tag_left .= '
    	<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .' (' . $tags[$i]->count . ')</a></li>
    ' . "\n";
        elseif ($i >= $percolumn && $i < $percolumn*2):
        $tag_mid .= '
    	<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .'  (' . $tags[$i]->count . ')</a></li>
    ' . "\n";
        elseif ($i >= $percolumn*2):
        $tag_right .= '
    	<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .' (' . $tags[$i]->count . ')</a></li>
    ' . "\n";
        endif;
    endfor;
    ?>
    
    <div class="list">
    <ul>
    <?php echo $tag_left; ?>
    </ul>
    </div>
    
    <div class="listlist">
    <ul>
    <?php echo $tag_mid; ?>
    </ul>
    </div>
    
    <div class="list">
    <ul>
    <?php echo $tag_right; ?>
    </ul>
    </div>

Topic Closed

This topic has been closed to new replies.

About this Topic