archives.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /*
  3. template name: 文章存档
  4. description: template for yusi123.com Yusi theme
  5. */
  6. get_header();
  7. ?>
  8. <div class="pagewrapper clearfix">
  9. <aside class="pagesidebar">
  10. <ul class="pagesider-menu">
  11. <?php echo str_replace("</ul></div>", "", ereg_replace("<div[^>]*><ul[^>]*>", "", wp_nav_menu(array('theme_location' => 'pagemenu', 'echo' => false)) )); ?>
  12. </ul>
  13. </aside>
  14. <div class="pagecontent">
  15. <header class="pageheader clearfix">
  16. <h1 class="pull-left">
  17. <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  18. </h1>
  19. <div class="pull-right">
  20. <?php deel_share() ?>
  21. </div>
  22. </header>
  23. <?php while (have_posts()) : the_post(); ?>
  24. <article class="article-content">
  25. <?php the_content(); ?>
  26. </article>
  27. <article class="archives">
  28. <?php
  29. $previous_year = $year = 0;
  30. $previous_month = $month = 0;
  31. $ul_open = false;
  32. $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');
  33. foreach($myposts as $post) :
  34. setup_postdata($post);
  35. $year = mysql2date('Y', $post->post_date);
  36. $month = mysql2date('n', $post->post_date);
  37. $day = mysql2date('j', $post->post_date);
  38. if($year != $previous_year || $month != $previous_month) :
  39. if($ul_open == true) :
  40. echo '</ul></div>';
  41. endif;
  42. echo '<div class="item"><h3>'; echo the_time('F Y'); echo '</h3>';
  43. echo '<ul class="archives-list">';
  44. $ul_open = true;
  45. endif;
  46. $previous_year = $year; $previous_month = $month;
  47. ?>
  48. <li>
  49. <time><?php the_time('j'); ?>日</time>
  50. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  51. <span class="muted"><?php comments_number('', '1评论', '%评论'); ?></span>
  52. </li>
  53. <?php endforeach; ?>
  54. </ul>
  55. </div>
  56. </article>
  57. <?php endwhile; ?>
  58. </div>
  59. </div>
  60. <?php get_footer(); ?>