random posts for custom select query?
-
Hi,
I have set up a custom select query using the following codex doc and it works well – it uses setup_postdata($post) to get posts:
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_QueryOne thing I would like to do is display only one random post, but I have tried
<?php query_posts('numberposts=1&orderby=rand'); ?>
and<?php $rand_posts = get_posts('numberposts=1&orderby=rand'); foreach( $rand_posts as $post ) : ?>but neither seem to do the trick.
Any ideas how to incorporate this functionality into the code:<?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?>Thanks,
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘random posts for custom select query?’ is closed to new replies.