i had been banging my head for almost a day but could not resolve it. i need to show one post from 4 xx categories here is my code
<?php
$cat_args = array(
'orderby' => 'name',
'order' => 'ASC',
'include' => '44,45,46,51'
);
$fcategories = get_categories($cat_args);
foreach($fcategories as $fcategory) {
echo '<dl>';
echo '<dt> <a href="' . get_category_link( $fcategory->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $fcategory->name ) . '" ' . '>' . $fcategory->name.'</a></dt>';
$post_args = array(
'showposts' => 1,
'category' => $fcategory->cat_ID
);
$fposts = get_posts($post_args);
foreach($fposts as $fpost) : setup_postdata($fpost); ?>
<dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd>
<?php
echo '<dd class="view-all"> <a href="' . get_category_link( $fcategory->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $fcategory->name ) . '" ' . '>View all posts in ' . $fcategory->name.'</a></dd>';
echo '</dl>';
endforeach;
}
?>
Every think seem to work perfectly except.... its showing only one post for all category while it should have shown one post from each category to be more specific its showing like
cat-1 cat-2 cat-3 cat-4 (this is ok)
post-1 post-1 post-1 post-1 (this is the prob)
while it should have been
cat-1 cat-2 cat-3 cat-4
post-1 post-2 post-3 post-4
Please help