Multiple Showpost Queries
-
Hi, I want to show the last 3 posts from 4 different categories and to do so I have to make 4 different queries which seems to be a lot (I already make several other queries on my home page). So I would like to know if there is a way to optimize these queries.
Here is my code:
<table width=”624″ cellpadding=”0″ cellspacing=”0″ border=”0″>
<tr>
<td width=”300″ align=”left” valign=”top”>Beach
<?php query_posts(‘showposts=3&category_name=Beach’); ?>
<?php while (have_posts()) : the_post(); ?>
” rel=”bookmark” title=”Read: <?php the_title(); ?>”><?php the_title(); ?>
<?php endwhile; ?>Roads
<?php query_posts(‘showposts=3&category_name=Roads’); ?>
<?php while (have_posts()) : the_post(); ?>
” rel=”bookmark” title=”Read: <?php the_title(); ?>”><?php the_title(); ?>
<?php endwhile; ?><td width=”24″ align=”center” valign=”center”></td>
</td>
<td width=”300″ align=”left” valign=”top”>Streets
<?php query_posts(‘showposts=3&category_name=Streets’); ?>
<?php while (have_posts()) : the_post(); ?>
” rel=”bookmark” title=”Read: <?php the_title(); ?>”><?php the_title(); ?>
<?php endwhile; ?>Buildings
<?php query_posts(‘showposts=3&category_name=Buildings’); ?>
<?php while (have_posts()) : the_post(); ?>
” rel=”bookmark” title=”Read: <?php the_title(); ?>”><?php the_title(); ?>
<?php endwhile; ?></td>
</tr>
</table>I would also like to do the same (show the last 3 posts from 4 differents tags from the same parent category.
Thank you for your help! 🙂
The topic ‘Multiple Showpost Queries’ is closed to new replies.