I wanted to change the WordPress archive in my ComicPress themed blog from a single long list of blog entries to multiple columns so that scrolling is minimised. I'm answering my own question here.
As a non programmer I am so chuffed to have slightly adapted the brilliant dynamic triple column layout solution by Jeff Star of Perishable Press to suit my needs. I'm sharing the adaption here.
My pride is only marginally dampened by the fact that what took me hours over days nibbling away like a dog on a bone would take a real programmer ten minutes or so without even giving it a second thought. That's why I'm not able to support it if goes wrong. Sorry.
I wanted the 3 col fix to list my blog entries by year. Not the total amount. And also to list it in pairs by date and title. My blog titles are only one word long. You can see the result here. http://www.stooryduster.co.uk/stooryduster-archives using the Comicpress theme.
I edited the archive-comic-year.php file by first php commenting out the code that created the existing one long single column table of a year's worth of entries.
I then pasted into that file the Perishable Press dynamic triple column solution by Jeff Star http://tinyurl.com/coa5v2 which gave me all my blog titles for the entire blog as three divs ready to make into a layout using CSS. It worked fine first time.
By a process of trial and error I found that adding this to the Perishable Press code:
'year='.$yearselect.'&showposts='.$columnThreePosts. got me my posts by year.
In effect replacing this, the original code:
<?php query_posts('showposts='.$columnOneTwoPosts.'&offset='.$columnOneOffset); ?>
with this, the new code:
<?php query_posts('year='.$yearselect.'&showposts='.$columnOneTwoPosts.'&offset='.$columnOneOffset); ?>
I then wanted to show my year blog entries by date title pairs. (Which should be a pair list but I was lazy and did it as a table. I'll fix it later.)
Again after trial and error I found the code changes required. Replacing this code:
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
with (bearing in mind I'm using tables) this code:
<tr><td class="archive-date"><?php the_time('M j') ?></td>
<td class="archive-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></td></tr>
When it is all together it looks like this code:
<table class="month-table"> <?php query_posts('year='.$yearselect.'&showposts='.$columnThreePosts.'&offset='.$columnThreeOffset); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<tr> <td class="archive-date"><?php the_time('M j') ?></td>
<td class="archive-title"><a href="<?php the_permalink() ?>">
<?php the_title(); ?></a></td> </tr>
<?php endwhile; endif; ?> </table>
Ignore the html and CSS and look at the php and you should be able to work out the differences.
'year='.$yearselect.'&showposts ' and
<?php the_time('M j') ?> are it.
Originally I had a number for the column division since I knew roughly the amount of posts per year. This was ugly so to get the post count numbers to do the division into an even three columns, after much trial and error, I replaced this code:
$count_posts = wp_count_posts(); $numposts = $count_posts->publish;
with this code:
$posts = &query_posts('showposts=-1&cat='.comicpress_all_comic_categories_string().'&year='.(int)$archive_year);
$numposts = count($posts);
To do the layout I wrapped the three divs that defined the columns in another div to act as a wrap and gave it a unique name.
In the CSS I set my layout to have column-01 float left, column-03 float right giving them widths to fit within a width set for the wrap div leaving enough room for the content of column-02 in between.
Finally before the closing of the wrap div and after all the column divs you need a class or a div that declares clear-both. Most themes have this style somewhere in their CSS.
Any other styling was to get it looking good to taste.
Again you can see the finished pages here http://www.stooryduster.co.uk/stooryduster-archives and analyse the styling if you want.
I typed this 2 weeks after I got it working so apologies if I've remembered what I did wrong. If I did I hope some PHP wizard will step in and correct the errors if any.