Did you know that you can place a limit on the number of posts in a WordPress Query? WordPress has a built in filter that you can use to take advantage of the MySQL SELECT statement LIMIT clause. In SQL, a LIMIT clause constrains the number of rows returned by the SELECT statement. Be careful when you use though, because on some server environments the LIMIT is applied to all queries on the page. This means menu items and widgets may also be limited to the defined number.
LIMIT takes one or two numeric arguments. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the first row is 0, not 1.
Each of the code snippets below limits query results set to 40 records. If you want to change that number, change the '40' in line 4 to your preference.
Add this code to functions.php to limit the number of posts returned in all queries:
Add this code to functions.php to limit the number of posts returned in search queries: