What’s the actual loop code that you’re using?
Thread Starter
sjlim
(@sjlim)
<div id="navBeta">
<h2>Site</h2>
<h3>(ToDo/WIP List)</h3>
<?php $posts = get_posts('numberposts=10&category=12'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<div class="postmeta">
<?php the_time('F j, Y') ?> at <?php the_time() ?>
</div>
<?php the_content(__('(more...)')); ?>
<div class="feedback">
<?php wp_link_pages(); ?>
</div>
<?php comments_template(); // Get wp-comments.php template ?>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
</div>
Thread Starter
sjlim
(@sjlim)
Anyone? The results can be seen in the link posted above.
I believe the php codeline has to end with a semi-colon <?php the_time(); ?>
He’s correct about the need for semi-colons. Also, this doesn’t make a whole lot of sense:
<?php $posts = get_posts('numberposts=10&category=12'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
What is the get_posts supposed to be doing here? You’ve combined two forms of loops in a rather unusual (and probably non-functional) way. I’m not certain, but this is probably the cause of your problems.
Use query_posts/have_posts/the_post alone, or use get_posts/foreach/setup_postdata alone, but don’t combine the two forms of loops. That’s just bad karma.
Thread Starter
sjlim
(@sjlim)
I have 2 loops on my page. Each loop is supposed to only return the results from a particular category. I am rather php ignorant. Any advice would be appreciated.
I have 2 loops on my page. Each loop is supposed to only return the results from a particular category.
Then you want to do something more like this:
<?php
query_posts('cat=1'); // first category ID
if (have_posts()) :
while (have_posts()) :
the_post();
?>
// do your post display stuff here
<?php
endwhile; endif;
rewind_posts(); // rewind so we can do a second loop
query_posts('cat=2'); // second category ID
if (have_posts()) :
while (have_posts()) :
the_post();
?>
// do your post display stuff here
<?php
endwhile; endif;
?>
Thread Starter
sjlim
(@sjlim)
Thanks Otto, I ended up using ‘query_posts’ too from the codex. Thank you!