I’m trying to output a list of posts that have a custom field value below a certain threshold (using it as a way to identify posts that have not “expired” – see http://wordpress.pastebin.com/HFzyqkT8 for the whole snippet).
The query below only seems to work if I set the order parameter to ascending, and also only displays the resulting posts if the posts_per_page parameter is set to -1. If is the the posts_per_page parameter to anything other than -1 nothing comes up.
<?php $my_query = new WP_Query('posts_per_page=-1&cat=-325,9&orderby=meta_value&meta_key=eventexpiry&order=asc'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
And when I check which vars are showing as being set/declared/queried..
[cache_results] => 1
[update_post_term_cache] => 1
[update_post_meta_cache] => 1
[posts_per_page] => 4
[comments_per_page] => 50
[order] => DESC
[orderby] => wpdb001_posts.post_date DESC
- The topic ‘posts_per_page only accepts -1 value’ is closed to new replies.