/ Published in: PHP
                    
                                        
This used to be code adapted from Z'Oc, but I decided to start again and write it fresh with WP_Query instead of get_posts.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function custom_archives_template() {
$cats = get_categories("hierarchical=0");
if ($cats) :
echo '<h2>By Category:</h2>';
foreach ($cats as $cat) :
$cat_name = $cat->cat_name;
$cat_id = $cat->cat_ID;
$cat_link = get_category_link($cat_id);
echo '<ul>';
echo ' <li class="cat_name"><h3>' . $cat_name . ' <span class="count">' . $cat->category_count . '</span></h3>';
$catposts = new WP_Query("showposts=-1&cat=$cat_id");
if ($catposts) :
echo ' <ul>';
while ($catposts->have_posts()) : $catposts->the_post();
echo ' <li><a href="' . get_permalink() . '">' . get_the_title() . '</a> <span>' . get_the_time('j F Y') . '</span></li>';
endwhile;
echo ' </ul>';
endif;
echo ' </li>';
echo '</ul>';
endforeach;
endif;
}
remove_action('thesis_hook_archives_template', 'thesis_archives_template');
add_action('thesis_hook_archives_template', 'custom_archives_template');
URL: http://www.z-oc.com/blog/2008/03/category-based-archive/
Comments
 Subscribe to comments
                    Subscribe to comments
                
                