Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There are 3 latest pages displaying on my WP. Here's the code.

<div id="main_posts">
<?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=3'.'&paged='.$paged . '&post_type=page' );
?>
<?php //query_posts('showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="main_post">
    <?php $image = get_post_meta($post->ID, 'Image', true); ?>
        <a href="<?php the_permalink(); ?>">
            <img class="post_image" width="251" height="292" src="<?php echo $image; ?>" alt="" />

            <div class="main_post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    </div>

I want to put 3 specific pages that I want on the main index page. How do I make it so?

share|improve this question

1 Answer 1

This should work by putting the good IDs. The paged attribute is useless here as you'll always show the same posts.

<div id="main_posts">
<?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(array(
        'showposts' => 3,
        //'paged' => $paged,
        'post_type' => 'page',
        'post__in' => array(1, 2, 3) // Your post IDs
    ));
?>
<?php //query_posts('showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="main_post">
    <?php $image = get_post_meta($post->ID, 'Image', true); ?>
        <a href="<?php the_permalink(); ?>">
            <img class="post_image" width="251" height="292" src="<?php echo $image; ?>" alt="" />

            <div class="main_post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    </div>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.