0

What am I missing?

<?  
//Specialities Query 
$args = array( 
 'post_type' => 'page',
 'post__in' => array(24, 26, 28),
 ) ;

$specialities_query = new WP_Query( $args );
// The Loop   
while ( $specialities_query->have_posts() ) :
 $specialities_query->the_post(); ?>
 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Read more on %s', 'karenmann' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" class="show"><?php the_title(); ?></a>
<? endwhile;
/* Restore original Post Data */ 
wp_reset_postdata(); ?>

returns 5 pages, id 7, 11 and then the three above 24,26,28. This query is in a sidebar and I normally manage these quite well I was originally using post_parent but also getting spurious results though slightly different to this and, at the end, including these three posts.

Site: development.karenmann.co.uk

1

Ids 7 & 11 are probably sticky posts.

Try this:

$args = array( 
 'post_type' => 'page',
 'post__in' => array(24, 26, 28),
 'ignore_sticky_posts' => 1
);
  • Well done! And the reason they are sticky posts.... because I've been trying the WP front end editor and it seems to make pages sticky for some reason. – Chris Pink Nov 17 '14 at 14:12

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.