The loop question
-
I am using this loop right now, however I need to modify it to just show the post’s from one catagory. I also found a piece code which lets you show only one catagory, but where do I place the code in the loop?
Here’s the loop I’m using right now:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2>
<small><?php the_time(‘j. F Y’) ?> <!– by <?php the_author() ?> –></small><div class=”entry”>
<?php the_content(‘Read the rest of this entry »’); ?>
</div><p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?>
</div><?php endwhile; ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Previous Entries’) ?></div>
<div class=”alignright”><?php previous_posts_link(‘Next Entries »’) ?></div>
</div><?php else : ?>
<h2 class=”center”>Not Found</h2>
<p class=”center”>Sorry, but you are looking for something that isn’t here.
<?php include (TEMPLATEPATH . “/searchform.php”); ?><?php endif; ?>
And here is the code to show one catagory:
<?php $my_query = new WP_Query(‘category_name=student&showposts=1’);
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<!– Do stuff… –>
<?php endwhile; ?>Where do I put this code in the loop?
- The topic ‘The loop question’ is closed to new replies.