page-archive.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. Template Name: 文章模版
  4. */
  5. get_header();
  6. ?>
  7. <?php while(have_posts()) : the_post(); ?>
  8. <article <?php post_class("post-item"); ?>>
  9. <?php the_content(); ?>
  10. <div id="archives-temp">
  11. <?php if(!iro_opt('patternimg') || !get_post_thumbnail_id(get_the_ID())) { ?>
  12. <h2><?php the_title();?></h2>
  13. <?php } ?>
  14. <div id="archives-content">
  15. <?php
  16. $the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1' );
  17. $year=0; $mon=0; $i=0; $j=0;
  18. $all = array();
  19. $output = '';
  20. while ( $the_query->have_posts() ) : $the_query->the_post();
  21. $year_tmp = get_the_time('Y');
  22. $mon_tmp = get_the_time('n');
  23. $y=$year; $m=$mon;
  24. if ($mon != $mon_tmp && $mon > 0) $output .= '</div></div>';
  25. if ($year != $year_tmp) { // 输出年份
  26. $year = $year_tmp;
  27. $all[$year] = array();
  28. }
  29. if ($mon != $mon_tmp) { // 输出月份
  30. $mon = $mon_tmp;
  31. array_push($all[$year], $mon);
  32. $output .= "<div class='archive-title' id='arti-$year-$mon'><span class='ar-time'><i class='iconfont icon-calendar'></i></span><h3>$year-$mon</h3><div class='archives archives-$mon' id='monlist' data-date='$year-$mon'>";
  33. }
  34. $output .= '<span class="ar-circle"></span><div class="arrow-left-ar"></div><div class="brick"><a href="'.get_permalink() .'"><span class="time"><i class="iconfont icon-time"></i>'.get_the_time('n-d').'</span>'.get_the_title() .'<em>('. get_comments_number('0', '1', '%') .')</em></a></div>';
  35. endwhile;
  36. wp_reset_postdata();
  37. $output .= '</div></div>';
  38. echo $output;
  39. ?>
  40. </article>
  41. <?php endwhile; ?>
  42. <?php get_footer(); ?>