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.

In my example you can see that i have to paginate posts from category 6 with meta_value='izhs' for meta_key='dachaizhs'

Now it works like it paginates the whole category, and then exclude from each page non-appropriate posts for searching meta_value.

So if i set 'posts_per_page'=9 for the query and i have 12 posts of current category, 2 of them are located on the 1st page and have meta_value="izhs" (which i'm querying) and on the 2nd page there are also some posts appropriate to searching meta-value (no matter how much).

As a result i receive on the 1st page only these 2 posts, while there are some posts i need on the 2nd page and my pagination of 9 posts per page seems to be broken.

Thanks a lot.

    $args = array(              
    'post_status'=>'publish',
    'post_type'=>'post',
    'orderby'=>'post_date',
    'order'=>'DESC' ,
    'posts_per_page' => 9,
    'paged' => get_query_var('paged'),
    'meta_key'=>'dachaIzhs',
    'meta_value'=>'izhs',
    'cat'=>6        
);

$query = new WP_Query ( $args );

while ( $query->have_posts() ) : $query->the_post();

// bla bla

endwhile;
share|improve this question
    
How about orderby = 'meta_value'? –  kaiser Oct 18 '11 at 15:54
    
Now it places well the posts i search within the pages but the number of pages isn't appropriate to the number of these posts. (For example: i have 9 posts per page set, 10 posts in category, 9 of them are of meta_value i need. As a result i have 1 correct page and the 2nd one is blank) –  mvod Oct 18 '11 at 16:18
1  
it seems as though maybe your pagination is based on the original query for the category page, but then you're creating a new, separate query with special conditions. –  Milo Oct 18 '11 at 17:02
    
@Milo good point. OP should add how he/she did the pagination. –  kaiser Oct 18 '11 at 17:10
    
I use WP-PageNavi. My pagination: if ( function_exists('wp_paginate') ) { wp_paginate(); } } How can I create the correct pagination? –  mvod Oct 18 '11 at 17:21
show 2 more comments

closed as too localized by toscho Jul 18 '12 at 21:20

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.