Skip to content

Commit a761e82

Browse files
committed
Update based on feedback
- Fix title. - Clarify description. - Avoid re-using key in same example array. - Make valid and invalid examples be a mirror. - Add missing `<em></em>` tags.
1 parent 4f6f0b9 commit a761e82

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

WordPress/Docs/WP/PostsPerPageStandard.xml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<documentation title="Flag returning high or infinite posts_per_page.">
1+
<documentation title="High Posts Per Page Limit">
22
<standard>
33
<![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.
4+
Using "posts_per_page" or "numberposts" with the value set to an high number opens up the potential for making requests slow if the query ends up querying thousands of posts. The default limit of 100 is configurable.
55
66
You should always fetch the lowest number possible that still gives you the number of results you find acceptable.
77
]]>
@@ -11,43 +11,58 @@ You should always fetch the lowest number possible that still gives you the numb
1111
<![CDATA[
1212
$args = array(
1313
'posts_per_page' => <em>-1</em>,
14+
);
15+
$args = array(
1416
'posts_per_page' => <em>100</em>,
17+
);
18+
$args = array(
1519
'posts_per_page' => <em>'10'</em>,
1620
);
1721
1822
$query_args['posts_per_page'] = <em>100</em>;
19-
$query_args['posts_per_page'] = <em>'10'</em>;
23+
24+
_query_posts( 'nopaging=1&posts_per_page=<em>50</em>' );
2025
]]>
2126
</code>
2227
<code title="Invalid: posts_per_page is over limit (default 100).">
2328
<![CDATA[
2429
$args = array(
25-
'posts_per_page' => <em>999</em>,
30+
'posts_per_page' => <em>101</em>,
2631
);
2732
28-
_query_posts( 'nopaging=1&posts_per_page=999' );
33+
$query_args['posts_per_page'] = <em>200</em>;
34+
35+
_query_posts( 'nopaging=1&posts_per_page=<em>999</em>' );
2936
]]>
3037
</code>
3138
</code_comparison>
3239
<code_comparison>
3340
<code title="Valid: numberposts is not over limit (default 100).">
3441
<![CDATA[
3542
$args = array(
36-
'numberposts' => -1,
37-
'numberposts' => 100,
38-
'numberposts' => '10',
43+
'numberposts' => <em>-1</em>,
3944
);
45+
$args = array(
46+
'numberposts' => <em>100</em>,
47+
);
48+
$args = array(
49+
'numberposts' => <em>'10'</em>,
50+
);
51+
52+
$query_args['numberposts'] = <em>'-1'<em>;
4053
41-
$query_args['numberposts'] = '-1';
54+
_query_posts( 'numberposts=<em>50</em>' );
4255
]]>
4356
</code>
4457
<code title="Invalid: numberposts is over limit (default 100).">
4558
<![CDATA[
4659
$args = array(
47-
'numberposts' => 999,
60+
'numberposts' => <em>101</em>,
4861
);
4962
50-
_query_posts( 'numberposts=999' );
63+
$query_args['numberposts'] = <em>'200'</em>;
64+
65+
_query_posts( 'numberposts=<em>999</em>' );
5166
]]>
5267
</code>
5368
</code_comparison>

0 commit comments

Comments
 (0)