I just want to show the last post from all categories on my page. For I could do this, I've made the following code:
<?php
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
foreach($categories as $category) {
$categoryId = $category->cat_ID;
query_posts('posts_per_page=1&cat=$categoryId');
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<span><?php echo $categoryId; ?></span>
<?php
endwhile;
endif;
}
wp_reset_query();
?>
But the posts displayed are all the same. What I've forgot?