you’ve got three different queries, but they’re all named the same thing. They need to be named differently. or even better, use “showposts=3” and a single query.
Thannks doodlebee.
Sorry for the basic coding question but I’m unsure how to code that. I tried the following:
<div class=”featured”>
<?php $recent = new WP_Query(“cat=1&showposts=2”); query_posts(1); while($recent->have_posts()) : $recent->the_post();?>
<h2>” rel=”bookmark”><?php the_title(); ?></h2>
<?php the_content(__(‘Read the story »’));?><div style=”clear:both;”></div>
<?php endwhile; ?>
</div>
Thanks,
Jackson
Sorry, also, where is the query name in the code?
Jackson
yeah – that second example is messed up.
All you have to do is replace your “showposts” with the number of posts you want to show.
<?php $recent = new WP_Query("cat=1&showposts=3"); if($recent->have_posts()); ?>
<div class="featured">
<?php while($recent->have_posts()) : $recent->the_post();?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('read the story »');?>
<?php endwhile; ?>
</div>
<?php endif; ?>
Cool, thanks. I tried that earlier which has the current result of showing the one post per one but it’s showing my most recent post 3 times where there should be 3 different posts. Not sure which part I should be changing to call up the individual posts?
Okay – huh? Sorry – but that’s worded really weird – I don’t quite understand what you’re saying.
I’ll try and break this down for you – maybe that’ll help.
$recent = new WP_Query(“cat=1&showposts=3”);
This sets up your query. It pulls the most recent 3 posts from the category with the ID of 1.
if($recent->have_posts());
this says “If there are posts in category 1…” and begins the Loop.
while($recent->have_posts()) : $recent->the_post();
..then while there are posts in category 1, then display them.
if it’s showing the same post three times, then my only guess is that you have a double loop going on. Your theme isn’t set up like this is it:
<?php if(have_posts()): while(have_posts()) : the_post(); ?>
<?php $recent = new WP_Query("cat=1&showposts=3"); if($recent->have_posts()); ?>
<div class="featured">
<?php while($recent->have_posts()) : $recent->the_post();?>
<h2><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('read the story »');?>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php endwhile; endif; ?>
if so, that’s your problem.
Sorry about the wording. It doesn’t look like it I know but I’ve installed WordPress themes and posted on numerous occasions but this theme’s giving me a headache.
This is from page.php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(__(‘Read more’));?><div style=”clear:both;”></div>
<!–
<?php trackback_rdf(); ?>
–>
<?php endwhile; else: ?>
<p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p><?php endif; ?>
</div>
</div>
<?php include(TEMPLATEPATH.”/sidebar.php”);?>
</div>
<!– The main column ends –>
<?php get_footer(); ?>
and this is from home.php:
<div class=”featured”>
<?php $recent = new WP_Query(“cat=1&showposts=1”); while($recent->have_posts()) : $recent->the_post();?>
<h2>” rel=”bookmark”><?php the_title(); ?></h2>
<?php the_content(__(‘Read the story »’));?><div style=”clear:both;”></div>
<?php endwhile; ?>
</div>
<div class=”featured”>
<?php $recent = new WP_Query(“cat=1&showposts=1”); query_posts(1); while($recent->have_posts()) : $recent->the_post();?>
<h2>” rel=”bookmark”><?php the_title(); ?></h2>
<?php the_content(__(‘Read the story »’));?><div style=”clear:both;”></div>
<?php endwhile; ?>
</div>
<div class=”featured”>
<?php $recent = new WP_Query(“cat=1&showposts=1”); while($recent->have_posts()) : $recent->the_post();?>
<h2>” rel=”bookmark”><?php the_title(); ?></h2>
<?php the_content(__(‘Read the story »’));?><div style=”clear:both;”></div>
<?php endwhile; ?>
</div>
Okay – well form what you’ve shown me, the only thing I can see that’s wrong is what Iv’e said before: all of your queries are named the same thing, which would definitely cause the “repeat” issue. But if you just replace ALL of them with the single query I posted above, it should be working fine. I’ve done it many, many times with no problems. So…I’m not sure what else to offer. Either I need to see the entire “home.php” file (use pastebin! don’t put it here!), or maybe someone else can come along and offer something else.
Thanks doodlebee, I’ve posted it to pastebin here:
http://pastebin.com/m2dbdbe1c
Jackson
Okay, that’s resolved.
It’s the category IDs I was having trouble with.
I’ve installed a plugin to reveal them and now all is well.
Thanks for all your help,
Jackson