get posts from one category to show in sidebar
-
I am using the template called Mystique. It uses widget ready sidebars, but I haven’t found one that does exactly what I need. I need for the sidebar to display the 6 last posts in the category “news” only on the index. I consider myself a novice with PHP so I’m having trouble getting this to work.
In the sidebar template, I’ve put in this code:
<ul> <?php if (is_home()); { global $post; $myposts = get_posts('numberposts=5&offset=1&category=news'); foreach($myposts as $post) : setup_postdata($post); } ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
So far, it’s not working. What else do I need to do to get it to work?
- The topic ‘get posts from one category to show in sidebar’ is closed to new replies.