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

  1. Lara Littlefield
    Posted 6 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.


    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>';
    	} ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 6 years ago by Lara Littlefield
  • This topic is not resolved
  • WordPress version: 2.9.1