Published on
<?php
// Query to get the latest 5 posts from a specific category
$args = array(
'post_type' => 'post',
'posts_per_page' => 5,
'category_name' => 'your-category-slug', // Replace with your category slug
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p>Published on <?php the_time('F j, Y'); ?></p>
<div><?php the_content(); ?></div>
<?php
}
wp_reset_postdata(); // Reset the query
} else {
echo 'No posts found in this category.';
}
?>