thomas514
Member
Posted 9 months ago #
I know how to display last posts for one specific cat, using:
<?php
// The Query
query_posts( 'cat=3' );
// The Loop
while (have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<h2><?php the_time('l j F Y') ?></h2>
<?php the_content('Lire la suite »'); ?>
<?php endwhile;
// Reset Query
wp_reset_query();
?>
But I did not find the way to display last x (4 for ex.) posts from different categories (for ex cat 2, 3 & 7). I want those posts to be displayed from the most recent one to the oldest one (of the 4).
I read this page but a bit messy for the beginner I am:
http://codex.wordpress.org/Template_Tags/query_posts
Any help would be higly appreciated!
thomas514
Member
Posted 9 months ago #
Here is now what I have in my query now, it displays 4 last posts from cat3:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=3&posts_per_page=4&paged=' . $paged);
But still having troubles to display 4 last posts of my website, post can come from different categories: I want to name them (for ex: cant 2, 3 & 7).
So I want to display 4 posts in total, from the new one to the oldest one (each of those 4 posts can come from one of those cat).
For all the parameters used by query_posts read this: http://codex.wordpress.org/Function_Reference/WP_Query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=2,3,7&posts_per_page=4&paged=' . $paged);
thomas514
Member
Posted 9 months ago #
works just great!
Thanks keesiemer!!