Scenario: Settings > Reading set to show 10 (or whatever number, doesn’t matter) latest blog posts (WordPress default).
And you want to display just 3 Posts without links to next sets of paginated pages.
So let’s just add this in functions.php:
https://gist.github.com/cdc430734b353fb57793Simple, right?
Apparently, that is not sufficient. When you reload your Posts page (the front page or the homepage, in this case) you’ll find that while only 3 Posts are displayed, pagination will continue to appear.
By setting no_found_rows
to true, we can truly retrieve a fixed number of posts thus getting rid of the pagination.
References:
http://wordpress.stackexchange.com/a/181553/14380
http://www.billerickson.net/code/improve-performance-of-wp_query/
[…] https://sridharkatakam.com/displaying-a-fixed-number-of-posts-in-wordpress-without-pagination/ […]