0

Can anyone tell me why this isn't working? Assuming two things here - 1. WP Query handles multiple page requests, and 2. doesn't need a reset because I'm creating a new WP Query. What happens is I only get the last page to be shown (389). Above this code on the same page there is another WP Query that only fetches one page. Could this be the reason, or is it the way I request the pages? I've tried applying all the reset handlers but they gave no effect.

The code -

<?php $promo = new WP_Query( array( 'post_type' => 'page', 'post__in' => array(62,18,389) ) ); while ($promo->have_posts()) : $promo->the_post(); ?>
<?php the_permalink() ?>
<?php the_post_thumbnail() ?>
<?php the_title() ?>
<?php the_excerpt() ?>
<?php endwhile; ?>
  • If you have found a solution, add it as an answer and mark your question as answered. – fuxia Mar 10 '12 at 8:53
1

Because your posts are only saved whithin the $promo var and not in the $wp_query global var. I recommend you to use get_posts() http://codex.wordpress.org/Template_Tags/get_posts

  • Thanks for the tip. I solved it using a get_pages query and a foreach loop instead. – Staffan Estberg Oct 27 '11 at 20:09
0

You need to do paging in the WP Query to make it work right (using paged parameter)

  • 3
    Welcome to WordPress Stack Exchange. May I ask you to add a small working example? Rather abstract one-liners are frustrating to read for most of our members. :) – fuxia Mar 10 '12 at 8:56

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.