Hi Benjee,
If you’d like to display only posts from a given category, you could try using this loop in the home page template:
<?php $my_query = new WP_Query('cat=1'); // display only category 1 posts
while($my_query->have_posts()) : $my_query->the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
This snippet should be good to display only posts from category 1. Adapt it to the category you’d like posts to be displayed from.
I hope this helps 🙂
– Maria Antonietta
Dear Maria Antonietta Perna, thank you, it works! Can I limit the number of item?
Adjust the code above like this:
new WP_Query('cat=1&posts_per_page=3')
This should limit the posts by category and number of posts.
Perfect! Thank you very much!