Random post from a random category
-
i love this nifty piece of code… it displays a random post from a random category π I’d love to see someone improve on it… I didn’t write this by the way.
<?php $temp_query = $wp_query; ?> <?php $postMonth = date('m'); ?> <?php $postYear = date('Y'); ?> <?php query_posts('cat=315,317,280&showposts=5&orderby=rand&monthnum='.$postMonth.'&year='.$postYear); ?> <?php while (have_posts()) : the_post(); ?> <div> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> in <?php foreach((get_the_category()) as $childcat) {echo $childcat->cat_name;}?> </li> </div> <?php endwhile; ?> <?php $wp_query = $temp_query; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Random post from a random category’ is closed to new replies.