Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8666229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:40:33+00:00 2026-06-12T17:40:33+00:00

I want to break up this archive list into multiple columns (three columns)…I don’t

  • 0

I want to break up this archive list into multiple columns (three columns)…I don’t want to use CSS3 for this. I can easily do this with wp_list_categories, but that method doesn’t work with wp_get_archives.

Ideally, I’d like to implement a counter to add in tags at an approximate 1/3 count…then I can use CSS for the rest.

CUSTOM ARCHIVE FUNCTION:

function wp_custom_archive($args = '') {
global $wpdb, $wp_locale;
$defaults = array(
    'limit' => '',
    'format' => 'html', 'before' => '',
    'after' => '', 'show_post_count' => false,
    'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
if ( '' != $limit ) {
    $limit = absint($limit);
    $limit = ' LIMIT '.$limit;
}
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format   = 'Y/m/d';
if ( !$archive_date_format_over_ride ) {
    $archive_day_date_format = get_option('date_format');
    $archive_week_start_date_format = get_option('date_format');
    $archive_week_end_date_format = get_option('date_format');
}
//filters
$where = apply_filters('customarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
$join = apply_filters('customarchives_join', "", $r);
$output = '<ul>';
    $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
    $key = md5($query);
    $cache = wp_cache_get( 'wp_custom_archive' , 'general');
    if ( !isset( $cache[ $key ] ) ) {
        $arcresults = $wpdb->get_results($query);
        $cache[ $key ] = $arcresults;
        wp_cache_set( 'wp_custom_archive', $cache, 'general' );
    } else {
        $arcresults = $cache[ $key ];
    }
    if ( $arcresults ) {
        $afterafter = $after;
        foreach ( (array) $arcresults as $arcresult ) {
            $url = get_month_link( $arcresult->year, $arcresult->month );
            /* translators: 1: month name, 2: 4-digit year */
            $text = sprintf(__('%s'), $wp_locale->get_month($arcresult->month));
            $year_text = sprintf('<li>%d</li>', $arcresult->year);
            if ( $show_post_count )
                $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
            $output .= ( $arcresult->year != $temp_year ) ? $year_text : '';
            $output .= get_archives_link($url, $text, $format, $before, $after);
            $temp_year = $arcresult->year;
        }
    }
$output .= '</ul>';
if ( $echo )
    echo $output;
else
    return $output;

}

CURRENT HTML OUTPUT (shortened):

<ul>
<li>2012</li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/09/' title='September'>September</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/08/' title='August'>August</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/07/' title='July'>July</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/06/' title='June'>June</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/05/' title='May'>May</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/04/' title='April'>April</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/03/' title='March'>March</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/02/' title='February'>February</a></li>
<li><a href='http://alittlesewing.com.s118336.gridserver.com/2012/01/' title='January'>January</a></li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:40:34+00:00Added an answer on June 12, 2026 at 5:40 pm

    If I understand correctly, you would have to do something like this

    $output = '<ul class="col1">';
    if ( $arcresults ) {
        $numarticles = count($arcresults);
        $column1 = round($numarticles/3);
        $column2 = round($column1*2);
        $counter = 0;
        $afterafter = $after;
        foreach ( (array) $arcresults as $arcresult ) {
            if($counter == $column1) {
               $output .= "</ul><ul class='col2'>";
            } elseif($counter == $column2)  {
               $output .= "</ul><ul class='col3'>";
            }
            $url = get_month_link( $arcresult->year, $arcresult->month );
            /* translators: 1: month name, 2: 4-digit year */
            $text = sprintf(__('%s'), $wp_locale->get_month($arcresult->month));
            $year_text = sprintf('<li>%d</li>', $arcresult->year);
            if ( $show_post_count )
                $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
            $output .= ( $arcresult->year != $temp_year ) ? $year_text : '';
            $output .= get_archives_link($url, $text, $format, $before, $after);
            $temp_year = $arcresult->year;
            $counter ++;
        }
        $output .= '</ul>';
    }
    

    This way, when the counter gets to a third of the way, it will add another list, so at the end you will have 3 lists.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if I can break this down to be less code.
I'm working on a large Node project. Naturally, I want to break this into
I want to break my program into multiple files 1. main.c - is the
I have a string such as: aabbccccdd I want to break this string into
I want to break down this URL into variables. http://example.com/user.php?u=38456 I want the value
I'm trying to use the CSS word-wrap property with break-word value. I want to
The author of this article states that Normally you don't want to have access
I want to use reactive-banana to write a traveller game that people can write
can some 1 tell how to break this sort of String in smarty what
I've got a string coming in like so: '202,203,204,205,226,230,274' I want to break this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.