You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<documentationtitle="Flag returning high or infinite posts_per_page.">
2
+
<standard>
3
+
<![CDATA[
4
+
Using posts_per_page (or numberposts) with the value set to an unreasonably high number or setting nopaging to true opens up the potential for scaling issues if the query ends up querying thousands of posts.
5
+
6
+
You should always fetch the lowest number possible that still gives you the number of results you find acceptable.
7
+
]]>
8
+
</standard>
9
+
<code_comparison>
10
+
<codetitle="Valid: posts_per_page is not over limit (default 100).">
11
+
<![CDATA[
12
+
$args = array(
13
+
'posts_per_page' => <em>-1</em>,
14
+
'posts_per_page' => <em>100</em>,
15
+
'posts_per_page' => <em>'10'</em>,
16
+
);
17
+
18
+
$query_args['posts_per_page'] = <em>100</em>;
19
+
$query_args['posts_per_page'] = <em>'10'</em>;
20
+
]]>
21
+
</code>
22
+
<codetitle="Invalid: posts_per_page is over limit (default 100).">
23
+
<![CDATA[
24
+
$args = array(
25
+
'posts_per_page' => <em>999</em>,
26
+
);
27
+
28
+
_query_posts( 'nopaging=1&posts_per_page=999' );
29
+
]]>
30
+
</code>
31
+
</code_comparison>
32
+
<code_comparison>
33
+
<codetitle="Valid: numberposts is not over limit (default 100).">
34
+
<![CDATA[
35
+
$args = array(
36
+
'numberposts' => -1,
37
+
'numberposts' => 100,
38
+
'numberposts' => '10',
39
+
);
40
+
41
+
$query_args['numberposts'] = '-1';
42
+
]]>
43
+
</code>
44
+
<codetitle="Invalid: numberposts is over limit (default 100).">
0 commit comments