1
0

page-archive.php 2.1 KB

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