Jump to content


Photo

Different number of posts on each page


  • Please log in to reply
8 replies to this topic

#1 LukeB

LukeB

    Super Member

  • Members
  • 139 posts
  • Framework Version:2.4.1
  • Country: Country Flag

Posted 25 October 2011 - 04:55 PM

Hi i was looking for a way to display a different number of posts on different pages. For example i would like only 1 or 2 posts to appear on the front page but say 7 or 8 in my category pages. Is there any way to do this? Regards Luke http://www.danceyrselfclean.com

#2 Kate

Kate

    Advocate

  • Members
  • 3039 posts

Posted 25 October 2011 - 04:59 PM

Hey Luke, You could add a hook to the functions.php file. Basically, the hook would use if statements to say, basically: if this page, then query_posts('posts_per_page=x')... Make sense?

#3 LukeB

LukeB

    Super Member

  • Members
  • 139 posts
  • Framework Version:2.4.1
  • Country: Country Flag

Posted 25 October 2011 - 05:48 PM

Would i be able to stick something in the custom CSS section to get it to work. Does something like this look along the right lines function limit_posts_per_archive_page() { if ( is_category() ) $limit = 2; elseif ( is_search() ) $limit = 1; else $limit = get_option('posts_per_page'); set_query_var('posts_per_archive_page', $limit); } add_filter('pre_get_posts', 'limit_posts_per_archive_page');

#4 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 25 October 2011 - 05:50 PM

What you've posted above is not CSS but a script, thus it would likely crash your site if placed in CSS Rules.

#5 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 25 October 2011 - 05:56 PM

First, in reply to your earlier query, you can control the number of posts on your front page (presuming it's static) you can use a plugin called TPG Get Posts there, with 2 posts. For the rest, you can simply change the settings for the number of posts to display at Settings > Reading on the left column of the WP Admin Dashboard.

#6 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 25 October 2011 - 06:17 PM

Here's the link: http://wordpress.org.../tpg-get-posts/

#7 LukeB

LukeB

    Super Member

  • Members
  • 139 posts
  • Framework Version:2.4.1
  • Country: Country Flag

Posted 28 October 2011 - 02:51 PM

Im not using a static page so i dont think that would work

#8 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 28 October 2011 - 03:10 PM

Have you seen this plugin?: http://www.maxblogpr...m/plugins/dppp/

#9 Jean-Philippe

Jean-Philippe

    Super Member

  • Members

  • 116 posts
  • LocationTokyo
  • Country: Country Flag

Posted 04 February 2012 - 11:23 AM

Here's another plugin: http://wordpress.org...posts-per-page/