[Resolved] Missing posts from query_posts
Hi all, I’m fairly new to WordPress although I have tinkered with a few pre-made templates to try and get the results I want before. For the first time ever I have embarked on the really fun (yet at the moment frustrating) world of creating a theme from scratch!
So far I have found it really rewarding, however I have come across a snag that I just can’t find the answer for, everything I read, including a tutorial from Lynda.com tells me I’m doing it right – it’s just not working as intended. I was hoping someone here would tell me that the problem is really obvious and give me a clue to what is going on.
Currently I am working off line (using MAMP) to design and set up the theme. I have a fixed home page which displays different categories and a list of the top 1-3 post headings of each one.
I am using query_posts to select a category and tell it how many posts I want, then a small local loop to get and display them, and then I reset the query ready for the next time.
I works a treat, although if I tell it to show me a number of posts, it will always show me one less than I ask for – and it always leaves off the latest – which is a major problem for the purpose of the site.
This happens on all instances of the query_posts loop (lets call it) on the page and it’s got be baffled. Here’s some mark up of one of the lists…
<h2 class="side-title">Pick of the day</h2> <?php query_posts('cat=33'.'&showposts=4'.'&orderby=date' ); the_post(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="latest-post"> <div class="recent-thumb"><img src="<?php echo get_post_meta($post->ID, 'thumb_med', true); ?>" /></div> <div class="sidebar-post"> <p class="side-cat"><?php the_date(); ?></p> <h5 class="side-name"><?php the_title(); ?></h5> </div> </div> <?php endwhile; endif; ?> <?php wp_reset_query(); ?>
The above code shows the main title, a thumbnail of the post, it’s title and the date. Ok so they are not links yet – I was coming back to that – but it seems to work beautifully, showing only 3 posts (not the coded 4, but I wanted 3!) however not the latest one.
Does anyone have an idea as to what is going on? There is no main loop on the page anywhere, and just another few of the above snippets where I want the lists to be. Is it just simply that I’m not working on a live site, I wouldn’t have thought so but I have to ask!
Please help someone, show me that I’m daft! 🙂 Thank you in advance.
- The topic ‘[Resolved] Missing posts from query_posts’ is closed to new replies.