Announcements

<ul id="post-list">
   <?php
   $args = array(
      'post_type' => 'post',
      'posts_per_page' => 10,
   );
   $query = new WP_Query($args);

   if($query->have_posts()) :
      while($query->have_posts()) : $query->the_post(); ?>
         <li><a href="#" class="post-title" data-id="<?php the_ID(); ?>"><?php the_title(); ?></a></li>
      <?php endwhile;
      wp_reset_postdata();
   endif;
   ?>
</ul>
document.addEventListener("DOMContentLoaded", function() { const links = document.querySelectorAll(".announcement-link"); const contentContainer = document.getElementById("announcement-content"); links.forEach(function(link) { link.addEventListener("click", function(event) { event.preventDefault(); const postId = this.getAttribute("data-post-id"); fetch("/wp-json/wp/v2/posts/" + postId) .then(function(response) { return response.json(); }) .then(function(post) { contentContainer.innerHTML = post.content.rendered; }) .catch(function(error) { console.error("Error fetching post:", error); }); }); }); });