WordPress.org

Ready to get started?Download WordPress

Forums

posts_per_page only accepts -1 value (2 posts)

  1. Jag Singh
    Member
    Posted 3 years ago #

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

    Array
    (
    [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?

  2. vtxyzzy
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic