Is there a way to modify the code below to get only posts from one category?
<? if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<? the_ID(); ?>"> <h3 class="storytitle"><a href="<? the_permalink() ?>" rel="bookmark"><? the_title(); ?></a></h3> <div class="info">Posted by <? the_author() ?> on <? the_time('F') ?> <? the_time('j') ?> under <? the_category(',') ?> <? edit_post_link(__('Edit This')); ?></div> <div class="storycontent"> <? the_content(__('Read the rest of this entry »')); ?> </div> <div class="info"> <? wp_link_pages(); ?> <? comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> </div> </div> <? comments_template(); // Get wp-comments.php template ?> <? endwhile; ?> <div class="alignleft"><p><? next_posts_link('« Previous Entries') ?></p></div> <div class="alignright"><p><? previous_posts_link('Next Entries »') ?></p></div> <? else : ?> <p><? _e('Sorry, no posts matched your criteria.'); ?></p> <? endif; ?>
I know there are several forum posts about this, but they're confusing. Some talk about "excluding categories" as a solution, which is cumbersome if you have many categories and often add new ones.
There are several plugins, but they don't seem very stable judging from the comments.
I use the code above on an index.php page outside WordPress. I still have trouble wrapping my head around The Loop.
The code above somehow gets the posts from the database, right? So it should be possible to just get the posts from a certain category, right?