Reputation: 21
I am trying to create a wordpress loop for only a specific category of posts. For some reason, the loop I am using for category does not seem to work. It simply displays all posts. As an example, I want to loop the category of "apples"
This is the code -
<?php get_posts('cat=apple'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
(Bunch of html/css)
<?php endwhile; endif; ?>
any ideas why it is not working?
Upvotes: 1
Views: 45
Reputation: 78
You are calling the category wrong, see https://codex.wordpress.org/Template_Tags/get_posts on how to set your arguments.
Upvotes: 1