Custom Archive Page


/ Published in: PHP
Save to your folder(s)

http://www.briangardner.com/archives/

http://diythemes.com/thesis/rtfm/create-customize-archives-page/


Copy this code and paste it in your HTML
  1. function my_archives_template() {
  2. echo '<ul>';
  3. $cat_args=array(
  4. 'orderby' => 'name',
  5. 'order' => 'ASC'
  6. );
  7. $categories=get_categories($cat_args);
  8. foreach($categories as $category) {
  9. $args=array(
  10. 'showposts' => 50,
  11. 'category__in' => array($category->term_id),
  12. 'ignore_sticky_posts'=>1
  13. );
  14. $posts=get_posts($args);
  15. if ($posts) {
  16. echo '<li><a href="' . get_category_link($category->term_id) . '" title="' . sprintf( __("View all posts in %s"), $category->name) . '" ' . '>' . $category->name .'</a></li>' . "\n";
  17. echo '<ul>';
  18. foreach($posts as $post) {
  19. setup_postdata($post);
  20. $ptitle = $post->post_title;
  21. $plink = get_permalink($post->ID);
  22. echo '<li><a href="' . $plink . '">' . $ptitle . '</a></li>'. "\n";
  23. } // foreach($posts
  24. echo '</ul>' . "\n";
  25. } // if ($posts
  26. } // foreach($categories
  27. echo '</ul>';
  28. }
  29.  
  30. remove_action('thesis_hook_archives_template', 'thesis_archives_template');
  31. add_action('thesis_hook_archives_template', 'my_archives_template');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.