Skip to content

Commit 8bbc265

Browse files
committed
Docs: Add PostsPerPage XML doc
See #1722.
1 parent d202e46 commit 8bbc265

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<documentation title="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+
<code title="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+
<code title="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+
<code title="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+
<code title="Invalid: numberposts is over limit (default 100).">
45+
<![CDATA[
46+
$args = array(
47+
'numberposts' => 999,
48+
);
49+
50+
_query_posts( 'numberposts=999' );
51+
]]>
52+
</code>
53+
</code_comparison>
54+
</documentation>

0 commit comments

Comments
 (0)