93 posts
  • Has been part of the Envato Community for over 1 year
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
QUAL says

My code (below) adds an action to increase the default, posts_per_page for all queries. Is this against the following rule? Should I use this rule only for home page?

Themes are not permitted to add options that define the number of posts to show on archive or category pages via a global setting.
My code: function my_function_to_increase_limit( $query ) { $query->set( 'posts_per_page', 24 ); } add_action(“pre_get_posts”, "my_function_to_increase_limit");
3503 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

Using pre_get_posts isn’t an issue, but you’re not allowed to adjust the posts_per_page that way because there is already a core WordPress setting to do that (Reading > Blog pages show at most). So your code will override the standard functionality, and that’s why it’s not allowed.

93 posts
  • Has been part of the Envato Community for over 1 year
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
QUAL says

Using pre_get_posts isn’t an issue, but you’re not allowed to adjust the posts_per_page that way because there is already a core WordPress setting to do that (Reading > Blog pages show at most). So your code will override the standard functionality, and that’s why it’s not allowed.
OK thanks, than I should use get_posts to define my limit. http://codex.wordpress.org/Template_Tags/get_posts
3503 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

If you’re running a secondary query, then yes – you can use get_posts()

If you’re modifying the main query, then you should use the pre_get_posts. You just shouldn’t make modifications that will prevent core settings from working.

93 posts
  • Has been part of the Envato Community for over 1 year
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
QUAL says

If you’re running a secondary query, then yes – you can use get_posts() If you’re modifying the main query, then you should use the pre_get_posts. You just shouldn’t make modifications that will prevent core settings from working.

Thanks! I have a final question. (sorry for too many questions)

I get all the posts with WP_Query for all of index, category, archive… Because I need more than 10 posts in my design. Is this against the following rule:

Themes are not permitted to add options that define the number of posts to show on archive or category pages via a global setting.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by