page-word.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Template Name: 说说模版
  4. */
  5. get_header();
  6. ?>
  7. <div id="primary" class="content-area">
  8. <main class="site-main" role="main">
  9. <?php
  10. $shuoshuo_per_page = iro_opt('shuoshuo_per_page'); //每页显示的说说数量
  11. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  12. $args = array(
  13. 'post_type' => 'shuoshuo',
  14. 'post_status' => 'publish',
  15. 'posts_per_page' => $shuoshuo_per_page,
  16. 'paged' => $paged
  17. );
  18. $shuoshuo_query = new WP_Query($args);
  19. ?>
  20. <div class="entry-content">
  21. <?php the_content( '', true ); ?>
  22. </div>
  23. <div class="cbp_shuoshuo">
  24. <?php if ($shuoshuo_query->have_posts()) : ?>
  25. <ul id="main" class="cbp_tmtimeline">
  26. <?php while ($shuoshuo_query->have_posts()) : $shuoshuo_query->the_post(); ?>
  27. <li id="shuoshuo_post">
  28. <a href="<?php the_permalink(); ?>">
  29. <span class="shuoshuo_author_img">
  30. <img src="<?php echo get_avatar_profile_url(get_the_author_meta('ID')); ?>" class="avatar avatar-48" width="48" height="48">
  31. </span>
  32. <div class="cbp_tmlabel">
  33. <object class="entry-content">
  34. <?php the_content( '', true ); ?>
  35. </object>
  36. <p class="shuoshuo_meta">
  37. <i class="fa-regular fa-clock"></i> <?php the_time('Y/n/j G:i'); ?>
  38. <span class="comments-number"><i class="fa-regular fa-comments"></i> <?php comments_number('0', '1', '%'); ?></span>
  39. </p>
  40. </div>
  41. </a>
  42. </li>
  43. <?php endwhile; ?>
  44. <?php wp_reset_postdata(); ?>
  45. </ul>
  46. <?php else : ?>
  47. <h3 style="text-align: center;">
  48. <?php _e('You have not posted a comment yet', 'sakurairo') ?>
  49. </h3>
  50. <p style="text-align: center;">
  51. <?php _e('Go and post your first comment now', 'sakurairo') ?>
  52. </p>
  53. <?php endif; ?>
  54. </div>
  55. </main><!-- #main -->
  56. <?php if (iro_opt('pagenav_style') == 'ajax') { ?>
  57. <div id="pagination">
  58. <?php next_posts_link(__('Load More', 'sakurairo'), $shuoshuo_query->max_num_pages); ?>
  59. </div>
  60. <div id="add_post">
  61. <span id="add_post_time" style="visibility: hidden;" title="<?php echo iro_opt('page_auto_load', ''); ?>"></span>
  62. </div>
  63. <?php } else { ?>
  64. <nav class="navigator">
  65. <?php previous_posts_link('<i class="fa-solid fa-angle-left"></i>') ?>
  66. <?php next_posts_link('<i class="fa-solid fa-angle-right"></i>', $shuoshuo_query->max_num_pages) ?>
  67. </nav>
  68. <?php } ?>
  69. </div><!-- #primary -->
  70. <script type="text/javascript">
  71. document.addEventListener('DOMContentLoaded', () => {
  72. const timelines = document.querySelectorAll('.cbp_tmtimeline');
  73. timelines.forEach(timeline => {
  74. timeline.addEventListener('mouseover', event => {
  75. if (event.target.matches('.cbp_tmtimeline li .shuoshuo_author_img img')) {
  76. event.target.classList.add('zhuan');
  77. }
  78. });
  79. timeline.addEventListener('mouseout', event => {
  80. if (event.target.matches('.cbp_tmtimeline li .shuoshuo_author_img img')) {
  81. event.target.classList.remove('zhuan');
  82. }
  83. });
  84. });
  85. });
  86. </script>
  87. <?php get_footer(); ?>