Community Forums › Forums › Design Tips and Tricks › Posts per Page per Catagory
Tagged: posts per page
This topic contains 4 replies, has 2 voices, and was last updated by UglyMutt 2 months, 3 weeks ago.
-
AuthorPosts
-
February 28, 2013 at 8:58 am #23271
Hello. I am having a bit of difficulty figuring out how to change the number of posts displayed on a per category basis. My homepage is currently functioning as wished with this modification:
add_action( ‘pre_get_posts’, ‘child_change_home_query’ );
/** Changes the query on the home page*/
function child_change_home_query( $query ) {if( $query->is_main_query() && $query->is_home() ) {
$query->set( ‘posts_per_page’, ’17′ );
$query->set(‘cat’, ‘-1,’);
}}
Now I wish to change how many posts show per category per page without it effecting my homepage. Most of my posts are fairly long with the exception of my “New Releases” category. I would like to set all categories to show 3 posts per page while the “New Releases” category shows 10 posts per page. If someone could offer any suggestions, I would be truly grateful.
If a point of reference is needed, my website is TopList-BestFictionBooks.com .
Thanks.
February 28, 2013 at 9:33 am #23281Did you try this plugin http://wordpress.org/extend/plugins/posts-per-category/
You could also modify code and add the conditional tag so it doesn’t effect your home page
!is_home()
You’ll need to add this code to a custom function.
<?php $page_num = $paged; if ($pagenum='') $pagenum =1; query_posts('showposts=3&paged='.$page_num); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> // WordPress loop endwhile;endif; ?>Source: http://www.wprecipes.com/how-to-define-how-many-post-to-display-per-page
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.February 28, 2013 at 11:18 am #23310Thank you for your response, Mr. Dalton. This is my first website attempt and, sorry to say, I’m not very savvy in the world of code and all it entails. I know it would be much simpler to use a plug-in to achieve the aesthetics I wish; however, I was told to shy away from plug-ins that aren’t deemed absolutely necessary and I already have three I feel imperative to my website. I was told plug-ins slow response time, not that I know exactly what that means, but I understood it to be negative.
Above, you mentioned adding the suggested code to a custom function. I googled custom functions for a tutorial and what I found was a bit confounding. Would you be able to point me to a simplified tutorial on how to create a custom function that even a novice would understand?
Thank you so very much for your help.
February 28, 2013 at 12:07 pm #23316I think the plugin is a better solution for you at this stage.
Doubt it will have any real affect on performance more than code will.
Coding would reqiure knowledge of conditional tags, query posts and the Genesis Loop.
http://www.w3schools.com/php/default.asp
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.February 28, 2013 at 1:18 pm #23331Thank you once again, Mr. Dalton. The tutorial you suggested is perfect for my level of understanding. In the mean time, I think I will just live with the aesthetic issue while I’m learning the nuts and bolts of code. I truly appreciate your assistance and wish you the best.
-
AuthorPosts
You must be logged in to reply to this topic.