I have a problem with my code, I want to display 3 specific pages on my homepage but my code is not working.. here’s the code..
<?php $args = array(
'post_type' => 'page',
'post__in' => array(3,5,7)
);
query_posts($args);
while (have_posts()) : the_post();
$do_not_duplicate = $post->ID; ?>
<div class ="date_author group">
<h3 class="date"><?php the_time('M j, y');?></h3>
</div>
<h3 class="title"><a STYLE="text-decoration:none" href = "<?php the_permalink();?>"><?php the_title();?></a></h3>
<?php the_excerpt();?>
<?php endwhile; ?>
This is an inappropriate use of
query_posts()
which is only for modifying the main query for the page. Additionally, even if you change your snippet to useget_posts()
, your template tags (e.g.the_excerpt()
) won’t work asget_posts()
isn’t a method of looping through posts, it just returns an array of posts.What you want is
WP_Query
. Change your first lines of code to this: