View Single Post
Old 06-25-2013, 04:05 AM  
vdbucks
Monger Cash
 
Industry Role:
Join Date: Jul 2010
Posts: 2,773
Quote:
Originally Posted by nico-t View Post
this works for me:

Code:
			<?php
			global $post;
			$myposts = get_posts('numberposts=6&category=3&orderby=rand');
			foreach($myposts as $post) :
			setup_postdata($post); ?>

					<?php
					global $more;
					$more = 0;
					?>

			<div class="postboxmain" id="post-<?php the_ID(); ?>">
			REST OF YOUR POST TEMPLATE HERE
			</div>

			<?php endforeach; 
			wp_reset_query(); 
			?>
Unless you're running a loop inside of a loop, or working directly with a wpdb query then there is absolutely no reason to use a foreach loop...
vdbucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote