WordPress.org

Support

Support » How-To and Troubleshooting » $found_posts issues when using WP_Query with meta_compare

$found_posts issues when using WP_Query with meta_compare

  • Hi,

    I’m just getting started in WP experience and I meet a little problem : I’m using this Wp_Query :

    $agenda = new WP_Query( array(
                      'cat' => getCurrentCatID(),
                      'meta_key' => 'date',
                      'meta_value' => getDateWithTol(),
                      'meta_compare' => '<',
                      'orderby' => 'meta_value_num',
                      'order' => 'ASC',
                      'post_status' => 'publish',
                      'posts_per_page' => get_option('posts_per_page'),
                      'paged' => (get_query_var('paged')) ?
                                  get_query_var('paged') : 1 ));

    This query return 4 posts, but the property $wp_query->found_posts returns 32 posts which creates problem with the plugin wp_paginate which creates more pages than it is needed…

    Is anybody has an idea or can hep me please ?
    Thanks a lot !

Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘$found_posts issues when using WP_Query with meta_compare’ is closed to new replies.
Skip to toolbar