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.

Haven’t slept in about 30 hours now, can someone please help as the below code doesn’t work, it just displays all posts etc :|

<?php $args = array
  (
        'page' => array(139, 54)
  );

  $loopy = new WP_Query($args);
  while ($loopy->have_posts()) : $loopy->the_post(); ?>
        <div class="item"><?php the_title(); 
              echo '<br ?>';

        echo '</div>';      
  endwhile; 

?>

share|improve this question

2 Answers 2

page is not an accepted parameter for WP_query , you can use page_id but that doesn't accept an array , only one specific ID, so just use post__in like this:

<?php $args = array(
        'post__in' => array(139, 54)
  );

  $loopy = new WP_Query($args);
  while ($loopy->have_posts()) : $loopy->the_post(); ?>
        <div class="item"><?php the_title(); 
              echo '<br ?>';

        echo '</div>';      
  endwhile; 

you can read more about the accepted parameters of wp_query at the codex

share|improve this answer
    
Thanks, doesn't seem to work though and the page ids are there –  Keith Donegan Mar 16 '11 at 0:30
    
or post_type => "any" if you are not expecting pages only –  Bainternet Mar 16 '11 at 0:43

Found the answer.

I have to tell wordpress I want posts in conjunction with Bainternet's code:

'post_type' => 'page',
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.