Support » Themes and Templates » Split by Month Archive List (wp_get_archives) into Two Columns

  • 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.


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

    // 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; ?>">
    		foreach($cat_array as $category) {
    		if($result_number % $cats_per_list == 0) {
    		echo $category.'</li>
    		<ul class="category_footer_post" id="cat-col-'.$list_number.'">';
    	else {
    		echo $category.'</li>';
    	} ?>
  • The topic ‘Split by Month Archive List (wp_get_archives) into Two Columns’ is closed to new replies.