ifacethoughts

posts_per_page

WordPress allows configuration for setting the number of posts to be displayed whenever an index archive (the typical homepage) or other archives like category or monthly archives are displayed. This option can be configured in the Blog Pages field Reading tab under Options menu in the administration User Interface. Note that there is a separate field for configuration number of posts to be displayed for syndication (feeds).

posts_per_page is set in the method get_posts of WP_Query.

Plugin and theme authors need not access this global variable directly. WordPress uses it internally to calculate the number of posts to be displayed.

Since the same setting is used for all archives Matt Read has developed a plugin where posts per page setting can be set for different types of archives, e.g., search, category, home, monthly, yearly, etc.

Back to full list of global variables.

Technorati tags: ,

Discussion [Participate or Link]

  1. Abhijit Nadgouda’s List of WordPress Global Variables « Lorelle on WordPress said:

    […] Post and Page Variables: wp_query, posts, more, posts_per_page, max_num_pages, numpages, page, pages, multipage, paged, post, id, authordata, post_cache, category_cache, and post_meta_cache […]

  2. Wordpress Global Variables | iface thoughts said:

    […] $posts_per_page […]

  3. Steven said:

    Good post. It did not have the complete answer I was looking for, but lead to it. I have this posted within my index.php prior to the loop that displays my posts. It is set in a “Recent Posts” section and my main page displays the recent 3 posts.

    query_vars[“posts_per_page”] = 3; $wp_query->get_posts(); ?>

    Thanks for the help

  4. Steven said:

    Code edit to last post. This is the correct code.

    query_vars["posts_per_page"] = 3; $wp_query->get_posts(); ?>

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
My bookmarks

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.