Random Posts, Multiple Queries
-
Hi all,
forgive the probably basic question, but I am new to WordPress and am slowly getting used to the code. Plus, I’m not a coder but a designer so everything takes a bit longer for me. I’d like to display a list of four random posts in a sidebar. The code I am using is working fine, but it is displaying all of the posts and I’d like to limit it to four. The tricky part is that because I am displaying each in a rounded-corner box, I need different queries.
The following works fine but is showing all of the posts and it is all in one box.
<div class="victories"> <div class="roundedcornr_top"><div></div></div> <div class="roundedcornr_content"> <?php query_posts('cat=4'. '&orderby=rand'); ?> <?php while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile;?> </div> <div class="roundedcornr_bottom"><div></div></div> </div>
This works fine, but if I put this in each box, I get a random post, but the same random post in each box.
<div class="victories"> <div class="roundedcornr_top"><div></div></div> <div class="roundedcornr_content"> <?php query_posts('cat=4'. '&orderby=rand'); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <div class="roundedcornr_bottom"><div></div></div> </div>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Random Posts, Multiple Queries’ is closed to new replies.