groups

name language licence
Use More Than One Loop On A Page, Without Printing Duplicate Posts PHP Other
Get Posts With A Specific Custom Field And Specific Value PHP Other
Create A Loop Of Images PHP Other
Using Multiple Loops PHP Other

< 1 2 >



language: PHP
licence: Other

Use More Than One Loop On A Page, Without Printing Duplicate Posts

options: view full snippetsend to code collector
Let’s start with the first loop. Nothing hard here: we’re just going to get the eight most recent posts using the showposts parameter. Open the index.php file, and paste the following code to output your “featured” posts:

<?php
query_posts('showposts=8');
$ids = array();
while (have_posts()) : the_post();
$ids[] = get_the_ID();
the_title();
the_content();
endwhile;
?>

Once that’s done, it’s time to apply our second loop and get all posts, excepted the ones we have already outputted in the first loop:

<?php
	
(Continues...)