WordPress.org

Ready to get started?Download WordPress

Forums

Split category list in columns then in pages (3 posts)

  1. bevi
    Member
    Posted 4 years ago #

    Hi, I've search a lot of this first just to find a solution but I only find some people with the same question or solutions than don't fixed my issue.
    What I need is a list of 2 or 4 columns of categories from some pattern category, but when the list has more than some quantity of categories the rest goes on other page.
    Something like this:

    "Category pattern title"

    Category 1 Category 4 Category 7\
    Category 2 Category 5 Category 8 | (categories of pattern category)
    Category 3 Category 6 Category 9/

    Next page > (to more categories of the same category pattern)

    I hope I explain correctly, I use wp-framework to put the design I need.
    Waiting for your good knowledge. Thanks!

  2. bevi
    Member
    Posted 4 years ago #

    Here is the code I use:

    <?php
    			if ( is_category( '1' )) {
    				echo '<h2>Cruise Line</h2>';
    
    $cats = explode("<br />",wp_list_categories('child_of=1&echo=0&hide_empty=0&orderby=ID&style=none&title_li='));
    $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;
    
    echo '<ul class="left">';
    echo $cat_left;
    echo '</ul>';
    echo '<ul class="right">';
    echo $cat_right;
    echo '</ul>';
    
    			}
    			elseif ( is_category( '3' )) {
    				echo '<h2>Destination</h2>';
    				wp_list_categories( 'child_of=3&hide_empty=0&orderby=ID&title_li=' );
    			}
    			elseif ( is_category( '4' )) {
    				echo '<h2>Duration</h2>';
    				wp_list_categories( 'child_of=4&hide_empty=0&orderby=ID&title_li=' );
    			}
    			else { ?>

    Pls, I really need your suggestion or help to resolve this.

  3. bevi
    Member
    Posted 4 years ago #

    If it helps to understand my question here is the url of the site:

    http://yiga.no-ip.org/mycruisereport

    Right now I put some code I founded to paginate the categories but don't show categories in cols, founded a code to put in cols too but not a solution of both codes together.

    Here is the thread where I found the solution to paginate category list
    http://wordpress.org/support/topic/336324?replies=17#post-1548386

    And here is the code like I can't find the original thread where I take this own :p :

    $cats = explode("<br />",wp_list_categories('child_of=1&echo=0&hide_empty=0&orderby=ID&style=none&title_li='));
    $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;
    
    echo '<ul class="left">';
    echo $cat_left;
    echo '</ul>';
    echo '<ul class="right">';
    echo $cat_right;
    echo '</ul>';

    Hope someone found this helpful and better once if someone can put both together in one solution.

Topic Closed

This topic has been closed to new replies.

About this Topic