When coding complex WordPress pages with more than one loop, <a Cheap nfl Jerseys href=”http://www.elitecheapnfljerseysauthentic.com/” target=”_blank”>wholesale nfl jerseys it can happen NFL Jerseys Cheap that cheap oakleys one of the loops doesn’t ПЛИТКИ behave Fake Ray Bans as expected: for example, unwanted offset, repeated posts, etc. Luckily, with a bit of knowledge and a very useful function, wholesale jerseys NFL Jerseys Cheap china we can avoid this.http://aton-mebel.ru
The following example features two distinct loops. Notice the rewind_posts()
function on line 8. This example can nba jerseys sales be used on any WordPress file as is: index.php, single.php, etc.
<span style="color: fake oakleys #ffcc00″>01 // First loop (get the last 3 posts in the “featured” category)
02 <?php query_posts(‘category_name=featured&showposts=3’); ?>
03 <?php while (have_posts()) : the_post(); nfl jerseys cheap ?>
04 <!– Do stuff… –>
05 <?php endwhile;?><br racha />
06
07 //loop reset
08 <?php rewind_posts(); ?><br своими />
09
10 //Second loop (Get all posts)
11 <?php while (have_posts()) : the_post(); ?>
12 <!– Do stuff… –>
13 <?php endwhile; ?>
Code Cheap Ray Bans explanation.
This piece of code doesn’t use any hacks; rewind_posts()
is a standard nfl oakley sunglasses sale jerseys cheap football jerseys cheap WordPress function.
The purpose of rewind_posts()
is to “clear” a loop that has been previously used (like the first loop in our example above), allowing you to use a second loop that isn’t affected by the first loop’s results.