Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add PostsPerPage XML doc #1732

Merged
merged 1 commit into from Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions WordPress/Docs/WP/PostsPerPageStandard.xml
@@ -0,0 +1,69 @@
<documentation title="High Posts Per Page Limit">
<standard>
<![CDATA[
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.

You should always fetch the lowest number possible that still gives you the number of results you find acceptable.
]]>
</standard>
<code_comparison>
<code title="Valid: posts_per_page is not over limit (default 100).">
<![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>,
jrfnl marked this conversation as resolved.
Show resolved Hide resolved
);

$query_args['posts_per_page'] = <em>100</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>101</em>,
);

jrfnl marked this conversation as resolved.
Show resolved Hide resolved
$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' => <em>-1</em>,
);
$args = array(
'numberposts' => <em>100</em>,
);
$args = array(
'numberposts' => <em>'10'</em>,
);

$query_args['numberposts'] = <em>'-1'<em>;

_query_posts( 'numberposts=<em>50</em>' );
]]>
</code>
<code title="Invalid: numberposts is over limit (default 100).">
<![CDATA[
$args = array(
'numberposts' => <em>101</em>,
);

$query_args['numberposts'] = <em>'200'</em>;

_query_posts( 'numberposts=<em>999</em>' );
]]>
</code>
</code_comparison>
</documentation>