Fetch Random Post in WP 2.0.11 Possible?
I’m still using 2.0.11 (for reasons I don’t feel like going into here). I have several query strings on my front page (index.php) that pull posts from various categories.
I wanted to create a box that would pull random posts from a certain category. I was so happy to remember this:
<!-- DISPLAY RANDOM QUOTE --> <div id="quotes"> <h2 class="headline">Someone Else Said it Better</h2> <?php query_posts('cat=47&showposts=2&orderby=rand'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <p class="rand-quote-text" id="post-<?php the_ID(); ?>"><?php the_title(); ?> <?php the_content(); ?> <?php endwhile; else: ?> <?php endif; ?> </div><!-- /quotes -->
But it dawns on me that this code only works for WP 2.5.x and higher. Do I have to use a plugin to do what I want here? Right now, I have a “Random Quotes” category, category ID 47. The page title is the quote itself and the body (content) is the author name. I think that’s easier than a plugin.
Any hope for me? Thanks!
- The topic ‘Fetch Random Post in WP 2.0.11 Possible?’ is closed to new replies.