Support » Fixing WordPress » posts_per_page only accepts -1 value

  • 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 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

    Any ideas?

Viewing 1 replies (of 1 total)
  • If I read your code correctly, it seems that you are excluding category 325, and only including category 9. Is that what you want, or did you want to also exclude 9? If so, you need to pur a minus sign in front of the 9.

Viewing 1 replies (of 1 total)
  • The topic ‘posts_per_page only accepts -1 value’ is closed to new replies.