Skip to content

Commit

Permalink
Update based on feedback
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
GaryJones committed Nov 2, 2019
1 parent 4f6f0b9 commit a761e82
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions WordPress/Docs/WP/PostsPerPageStandard.xml
@@ -1,7 +1,7 @@
<documentation title="Flag returning high or infinite posts_per_page.">
<documentation title="High Posts Per Page Limit">
<standard>
<![CDATA[
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.
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.
You should always fetch the lowest number possible that still gives you the number of results you find acceptable.
]]>
Expand All @@ -11,43 +11,58 @@ You should always fetch the lowest number possible that still gives you the numb
<![CDATA[
$args = array(
'posts_per_page' => <em>-1</em>,
);
$args = array(
'posts_per_page' => <em>100</em>,
);
$args = array(
'posts_per_page' => <em>'10'</em>,
);
$query_args['posts_per_page'] = <em>100</em>;
$query_args['posts_per_page'] = <em>'10'</em>;
_query_posts( 'nopaging=1&posts_per_page=<em>50</em>' );
]]>
</code>
<code title="Invalid: posts_per_page is over limit (default 100).">
<![CDATA[
$args = array(
'posts_per_page' => <em>999</em>,
'posts_per_page' => <em>101</em>,
);
_query_posts( 'nopaging=1&posts_per_page=999' );
$query_args['posts_per_page'] = <em>200</em>;
_query_posts( 'nopaging=1&posts_per_page=<em>999</em>' );
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: numberposts is not over limit (default 100).">
<![CDATA[
$args = array(
'numberposts' => -1,
'numberposts' => 100,
'numberposts' => '10',
'numberposts' => <em>-1</em>,
);
$args = array(
'numberposts' => <em>100</em>,
);
$args = array(
'numberposts' => <em>'10'</em>,
);
$query_args['numberposts'] = <em>'-1'<em>;
$query_args['numberposts'] = '-1';
_query_posts( 'numberposts=<em>50</em>' );
]]>
</code>
<code title="Invalid: numberposts is over limit (default 100).">
<![CDATA[
$args = array(
'numberposts' => 999,
'numberposts' => <em>101</em>,
);
_query_posts( 'numberposts=999' );
$query_args['numberposts'] = <em>'200'</em>;
_query_posts( 'numberposts=<em>999</em>' );
]]>
</code>
</code_comparison>
Expand Down

0 comments on commit a761e82

Please sign in to comment.