[wp-hackers] new WP_Query filter with meta_value and with pagination - unexpected behaviour

Ash Goodman ash at thinkinginvain.com
Mon Apr 26 09:40:15 UTC 2010


Hi all

I have found some strange behaviour when using a new WP_Query and filtering
the loop with meta_value=

as shown below ( on my front_page )

<?php $temp = $wp_query;
$wp_query= null;
$wp_query = new
WP_Query("showposts=1&meta_value=_fprofile&post_type=page"."&paged=".$paged);
while($wp_query->have_posts()) : $wp_query->the_post();?>

The problem is pagination is not working properly. When I click the next
page link I am taken out of my loop and into the loop found on index.php
Meaning into the normal blog post link giving me posts instead of pages, no
meta_value filter and 10 post per page instead of 1. It seems to switch
loops?

This problem is eliminated by making the loop on index.php fire only if
is_home()

<?php if(is_home()) {?>

Normal blog post loop

<?php }else{?>
<!-- do nothing -->
<?php } ?>


This doesn't seem to cause any other problems so I am hopeful the situation
is sorted, BUT

It feels kind of off to me somehow. Is the behaviour I am seeing expected or
is it a bug? Should my loop switch like that on going to the second page?
And is my fix ok or is it likely to cause other problems - for example screw
with categories or archives?

Thanks!

Ash


More information about the wp-hackers mailing list