• cognitions

    (@cognitions)


    A number of people on the forum have asked how to display wp_list_categories and wp_list_pages in 2 Columns.

    wp_list_categories in two columns has been provided in a number of ways, including the simple code below (courtesy:
    https://www.livexp.net/wordpress/display-list-of-wordpress-categories-in-two-columns.html.)
    I have spent ages fiddling with it to adapt it so it will display wp_list_pages in 2 columns. Just cannot quite get there.

    Is there anyone who knows how this might be done.

    Many thanks.

    <?php
    $cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none'));
    $cat_n = count($cats) - 1;
    for ($i=0;$i<$cat_n;$i++):
    if ($i<$cat_n/2):
    $cat_left = $cat_left.'<li>'.$cats[$i].'</li>';
    elseif ($i>=$cat_n/2):
    $cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
    endif;
    endfor;
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying wp_list_pages in 2 Columns’ is closed to new replies.