Interesting question. Wp_Query
will return all posts that match the criteria. To enhance performance, you can switch off pagination with no_found_rows=true
. You want both pagination and limit the amount of results returned. That’s not something wp_query
can deliver.
So the most obvious though not too elegant solution would be to modify your loop in the same way you modify your pagination to cut off the superfluous results:
while( $query->have_posts() ) {
if (($wp_query->current_post) =< 10 ) {
$query->the_post();
the_title();
}
}
An alternative way would be to use wpdb
and build your own mysql query. Or use no_found_rows
and build your own pagination for the results.
Related Posts:
- Multiple WP_Query loops with Pagination
- Pagination returns 404 after page 20
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- Pagination with 5 posts per page
- Pagination/infinite scroll with WP_Query and multiple loops
- Pagination Not working on Home Page with 2 Query
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- Transient pagination not working properly
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Woocommerce custom loop to show all the products [closed]
- How to bring specific post to front of wordpress loop?
- Pagination stops at page 6
- Paginated HTML Sitemap
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination is broken and I need help fixing it
- Storing query variable and then using wp_reset_query
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Five posts from a category in footer
- posts_per_page not working for first page of pagination
- How do I get my custom query to work with search results after the first page?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Second loop pagination changes URL, not content
- I am officially missing something about transient posts
- Query Not working as expected
- Paginate pages with dynamic query
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Pagination inside the blog page not working
- Custom Query Pagination not working on static front page
- Paging works correctly on local version, but not live?
- Problem with custom WP_Query and underlying pagination/posts_per_page
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Pagination returns 404 after page 20
- custom query – offset to pagination
- Pagination not working with WP_QUERY
- No content found on page 2 of pagination with 1 post per page
- wp_query pagination links producing 404
- Loop being strainge
- Pagination in custom query not working [duplicate]
- Multiple loops on index page with sticky post and pagination
- Pagination problem with multiple loops on the same page
- Show number of posts AND number on current page (cannot make it work)
- Pagination only showed when no category is set in wp_query
- Can I force WP_Query to return no results?
- WP_Query and next_posts_link
- paginate_links() adds empty href to first page and previous link
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- How can I save an array from a random post sequence for later use?
- Pagination custom query
- How to order category.php loop by ‘meta_value’?
- Move posts to top of WP_Query if in certain Taxonomy?
- ‘paged’ in wp_query doesn’t work
- WP Query with offset breaks wp_pagenavi or any pagination
- Get List of all the Authors
- WP_Query loop within WP_Query loop
- Sub-loop / nested loops Best Practices
- Show Sticky Post at the top but do not show again in the loop?
- Any number in meta key (wp query)
- How do I get the title of a category in a custom loop?
- Blog post per page setting conflicting with custom WP_Query?
- Out Of memory issue on post per page parameter
- Avoid repeated post on page 2 when excluding one on page 1
- Multiple Loops on category.php with pagination on last loop
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- Assign custom parameter to each post in query
- Include latest author posts with pagination in single template?
- how to get category`s slug in WP_Query loop?
- How to remove only the latest sticky post from the loop
- Advise on Templates for Custom Queries
- Query WP Page for Buddypress Group Home [closed]
- $post in wp_query?
- How to pass the current content of $wp_query to a new page?
- How to separate two columns from one content on a page template?
- WP_query pagination on frontpage
- Can I alter the main loop to ‘orderby’ a custom callback?
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Avoid removing duplicate posts
- Repeat array inside array through while loop
- What’s causing an infinite loop?
- pages shortcode filtering by category
- Showing the correct number of posts_per_page when avoiding the use of post__not_in
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to set up pagination for a custom loop on a global template (author.php, tag.php, archive.php?)
- display post multiple times based on array of dates
- WP_Query secondary query failing
- Custom search (wp query by custom fields)
- Sorting is not working in WordPress WP_Query
- Add custom WP_Query after the first 3 posts
- Limit the number of posts from a specific category on index.php
- Why won’t my paged wp_query work? [duplicate]
- Pagination doesn’t work for home page custom post type query
- Loop issues when creating custom query for media uploader
- Query multiple taxonomies with pagination
- Carousel Loop only duplicating
- How to show featured post first, then separate loop for other posts
- error with $query->have_posts()