I have the following code setup as a page template and assigned to a page:
<?php if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<?php
echo $post->ID;
$thumb = get_post_meta($post->ID, 'Thumbnail', true);
?>
<p><img src="<?php echo $thumb; ?>"</p>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1><?php the_title(); ?></h1>
<?php the_excerpt(); ?>
<?php the_content(); ?>
</div><!-- #post-## -->
<?php endwhile; ?>
<?php endif; ?>
I curently have this page template on post=21. Now this all work fine but it only works for the page this template is assigned to.
I actually don’t want this to be part of a template but I just want to use the code within my index.php file but I actually would like it to loop through these pages, i.e. 21,22,23 only, inorder to retrieve the info I have requested here.
Can someone please assist on how to pass the page id into this loop or how to make it loop just through pages 21,22 and 23.
This has got me stuck.
Thanks.
before your code, add:
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
Perhaps something like this
See more here