I am trying to have a list in my left sidebar that will show the previous ten posts and, ideally, display the tag next to the link if the post has one of three specific tags. At this point, though, I'd just be happy getting it to display the name of the first tag. (I figured it would be a good starting place)
So I put the following into my sidebar
<?php query_posts('showposts=10'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a>
<?php $category = get_the_category();
echo $category[0]->cat_name;?></li>
That works, but unfortunately it seems to break the rest of my blog. When that code is present in my sidebar, all other pages (posts, single pages, etc.) just display the contents of my index.
I've read through the codex and tried using the multiple loop suggestions, but I can't get anything to work.