random new post
-
Ok, a question about the loop.
I have my category “news”, with 10 posts.
I want the loop to find the latest 3, and display only 1 of them (at random)I guess i could do something like this…
$query = WP_Query('category_name=news&orderby=date&posts_per_page=3'); $rand = rand(1, 3); $count = 1; while($query->have_posts()): if($rand != $count){ $count++; continue; } // Display post here endwhile;
…but its not pretty.
Any sugestions, can i do this just with the right loop arguments?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘random new post’ is closed to new replies.