Jump to content
Sign in to follow this  
LukeB

Different number of posts on each page

Recommended Posts

LukeB    0
LukeB

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

Share this post


Link to post
Share on other sites
Kate    3
Kate
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?

Share this post


Link to post
Share on other sites
LukeB    0
LukeB
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');

Share this post


Link to post
Share on other sites
Rob    547
Rob
What you've posted above is not CSS but a script, thus it would likely crash your site if placed in CSS Rules.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Rob    547
Rob
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.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Rob    547
Rob
Here's the link: http://wordpress.org/extend/plugins/tpg-get-posts/

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
LukeB    0
LukeB
Im not using a static page so i dont think that would work

Share this post


Link to post
Share on other sites
Jean-Philippe    2
Jean-Philippe
Here's another plugin: http://wordpress.org/extend/plugins/custom-posts-per-page/

www.photoreview.fr | www.kankei.fr

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×