WordPress.org

Ready to get started?Download WordPress

Forums

Split by Month Archive List (wp_get_archives) into Two Columns (1 post)

  1. Lara Chelak
    Member
    Posted 4 years ago #

    I've searched and searched and tried and tried to find something that will work. I've found bunches of solutions for categories... I modify them to try it with archives and it just ends up dumping the two columns after the list of archives it output.

    Arghh!

    This is the basic modification I've been trying to use:

    <?php
    // Grab the categories - top level only (depth=1)
     $get_cats = wp_get_archives( 'type=daily' );
    // Split into array items
     $cat_array = explode('</li>',$get_cats);
    // Amount of categories (count of items in array)
     $results_total = count($cat_array);
    // How many categories to show per list (round up total divided by 5)
     $cats_per_list = ceil($results_total / 5);
    // Counter number for tagging onto each list
     $list_number = 1;
    // Set the category result counter to zero
     $result_number = 0;
    ?>
    
    <ul class="category_footer_post" id="cat-col-<?php echo $list_number; ?>">
    
    	<?php
    		foreach($cat_array as $category) {
    		$result_number++;
    
    		if($result_number % $cats_per_list == 0) {
    		$list_number++;
    		echo $category.'</li>
    		</ul>
    
    		<ul class="category_footer_post" id="cat-col-'.$list_number.'">';
    
    	}
    
    	else {
    
    		echo $category.'</li>';
    
    		}
    
    	} ?>
    
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic