page-word.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Template Name: 说说模版
  4. */
  5. get_header();
  6. ?>
  7. <div id="primary" class="content-area">
  8. <main id="main" class="site-main" role="main">
  9. <?php
  10. $args = array(
  11. 'post_type' => 'shuoshuo',
  12. 'post_status' => 'publish',
  13. 'posts_per_page' => -1
  14. );
  15. $shuoshuo_query = new WP_Query($args);
  16. ?>
  17. <div class="cbp_shuoshuo">
  18. <?php if ($shuoshuo_query->have_posts()) : ?>
  19. <ul class="cbp_tmtimeline">
  20. <?php while ($shuoshuo_query->have_posts()) : $shuoshuo_query->the_post(); ?>
  21. <li>
  22. <span class="shuoshuo_author_img"><img src="<?php echo get_avatar_profile_url(get_the_author_meta('ID')); ?>" class="avatar avatar-48" width="48" height="48"></span>
  23. <div class="cbp_tmlabel">
  24. <p><?php the_content(); ?></p>
  25. <p class="shuoshuo_time"><i class="fa-regular fa-clock"></i> <?php the_time('Y/n/j G:i'); ?></p>
  26. </div>
  27. </li>
  28. <?php endwhile; ?>
  29. </ul>
  30. <?php else : ?>
  31. <h3 style="text-align: center;"><?php _e('You have not posted a comment yet', 'sakurairo') ?></h3>
  32. <p style="text-align: center;"><?php _e('Go and post your first comment now', 'sakurairo') ?></p>
  33. <?php endif; ?>
  34. </div>
  35. <?php wp_reset_postdata(); ?>
  36. </main><!-- #main -->
  37. </div><!-- #primary -->
  38. <script type="text/javascript">
  39. document.addEventListener('DOMContentLoaded', () => {
  40. const timelines = document.querySelectorAll('.cbp_tmtimeline');
  41. timelines.forEach(timeline => {
  42. timeline.addEventListener('mouseover', event => {
  43. if (event.target.matches('.cbp_tmtimeline li .shuoshuo_author_img img')) {
  44. event.target.classList.add('zhuan');
  45. }
  46. });
  47. timeline.addEventListener('mouseout', event => {
  48. if (event.target.matches('.cbp_tmtimeline li .shuoshuo_author_img img')) {
  49. event.target.classList.remove('zhuan');
  50. }
  51. });
  52. });
  53. });
  54. </script>
  55. <?php
  56. get_footer();
  57. ?>