using $myposts to fetch posts from a specific catagory
I’ve been trying to set up a page template that will include a sidebar displaying post information from a certain category.
I can display the posts fine, but I cannot make it only use the categories(that I set when I publish the post).
Here is what I have so far:
<?php global $post; $myposts = get_posts('numberposts=5&offset=news&category=news'); foreach($myposts as $post) : setup_postdata($post); ?> <div class="excerpt"> <div class="excerpttitle"> <?php the_title();?> </div> <div class="thumbnail"> <?php the_post_thumbnail( 'thumbnail' ); ?> </div> <div class="excerpttext"> <p><?php the_excerpt(); ?></p> </div> <span class="readmore"><a href="<?php the_permalink(); ?>">Read More</a></span> </div> <?php endforeach; ?>
- The topic ‘using $myposts to fetch posts from a specific catagory’ is closed to new replies.