I've stared at this for the last hour and can't figure out what the problem is, so maybe a pair of fresh eyes will be able to spot what is wrong.
So, I'm using query_posts to call different numbers of posts from different categories on my pages. This has worked without any problems so far. For example on my index page I have two content boxes which display certain content from 2 seperate categories. Than in my sidebar I have used it to display the last three posts from another category.
So, what I want to do next is use it for my navigation to control the list of title links to the posts. So this is the code I have used:
<ul id="nav"> <li><a href="<?php echo get_option('home'); ?>" class="home">Home</a></li> <li><a href="/about" class="about">About</a></li> <li><a href="/services" class="services">Services</a></li> <li><a href="#" class="athletes">Athletes</a> <ul> <?php query_posts('showposts=20&cat=5'); ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> </li> <li><a href="/timetables" class="timetables">TimeTables</a></li> <li><a href="/blog" class="blog">Blog</a></li> <li><a href="#" class="contact">Contact</a></li> </ul>
But, when I place this code in my header.php file, and upload it to the site all the pages and posts point to the last post in category id #5. For some reason I guess the loop isn't ending for that section, but I'm not sure why? Is it because it's in my header.php file? When I remove the code from my header.php file everything returns to normal.
Suggestions, ideas, solutions?