WordPress.org

Ready to get started?Download WordPress

Forums

Limit entries of WPQuery (2 posts)

  1. lonesomewalker
    Member
    Posted 4 months ago #

    Hello everybody,

    when using this query, i don't get unlimited entries, they get cut of at 10 entries.

    $metaQuery = array(
    	'relation' => 'AND'
    );
    
    $metaQuery[] = array(
    	'key' => 'isvisible',
    	'value' => '1',
    	'compare' => '='
    );
    
    $args = array(
    	'numberposts' => -1,
    	'post_type' => 'portfolio',
    	'meta_query' => $metaQuery
    );
    
    $entries = array();
    $the_query = new WP_Query($args);
    while($the_query->have_posts()){
    	$the_query->the_post();
    	$entries[] = array(
    		"id" => get_the_id(),
    		"title" => get_the_title(),
    		"mapentry" => get_field("mapentry"),
    		"street" => get_field("street"),
    		"postal" => get_field("postal"),
    		"city" => get_field("city"),
    		"link" => get_permalink(),
    		"thumbnail" => get_field("thumbnail")
    	);
    }

    When i print_r this query, i get a:
    DESC LIMIT 0, 10;
    at the end...?

    So, where is the knot? :-)

  2. vtxyzzy
    Member
    Posted 4 months ago #

    Try using 'posts_per_page' instead of 'numberposts'.

Reply

You must log in to post.

About this Topic