0

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; 

?>

3

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

  • 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
0

Found the answer.

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

'post_type' => 'page',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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