using get_posts before loop
-
I’m working on a theme from a design at oswd.org, and the design has a list of recent posts above the header. I’m able to get two columns of 3 posts titles with links no problem using the get_post template tag:
?php
$posts = get_posts('numberposts=3');
foreach($posts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
and adding an offset= in the second column.
However, no matter what I do, I’m getting a mysql database error when the page lists the posts in the content. Remove the get_posts queries, and the error goes away.
Example here
What am I missing. This code works fine in the sidebar, can it simply not be used before the loop?
EDIT I am using 2.0 on this testbed site, but the error occured on a 1.5.2 site as well.
- The topic ‘using get_posts before loop’ is closed to new replies.