Community Forums › Forums › Archived Forums › Design Tips and Tricks › How can I limiting the number of blog posts only on the homepage of Minimum?
Tagged: Genesis Grid Loop, minimum, posts
- This topic has 4 replies, 3 voices, and was last updated 11 years, 8 months ago by
giraffeweb.
-
AuthorPosts
-
May 30, 2013 at 11:23 am #43246
Chris Moore
MemberHello,
Looking for a way to limit the number of posts that show up only on the homepage of the Minimum child theme.
I am currently editing this code found in the `home.php` file of the Minimum child theme:
`add_action( 'genesis_loop', 'minimum_grid_loop_helper' );
function minimum_grid_loop_helper() {if ( function_exists( 'genesis_grid_loop' ) ) {
genesis_grid_loop( array(
'features' => 0,
'feature_image_size' => 'featured',
'feature_image_class' => 'post-image',
'feature_content_limit' => 0,
'grid_image_size' => 0,
'grid_image_class' => 'alignnone',
'grid_content_limit' => 250,
'posts_per_page' => 2, // added this
'more' => __( '[Read more]', 'minimum' ),
) );
} else {
genesis_standard_loop();
}}`
It seems that the 'posts_per_page' in this code snippet is not doing it's job of limiting the posts to only 2.
Note: I have the SETTINGS --> READING "Blog pages show at most" set to 6 because I want other pages on the site to show 6 posts (like the archive and category pages). But I still want to limit the amount of posts that show on the homepage and I just can't get it to work.
Thanks for your help!
http://moorecreativeideas.comResepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comMay 30, 2013 at 11:39 am #43248Chris Moore
MemberWell, looks like I solved it!
I just added this to the `functions.php` and voila, only 2 posts on the homepage now!
`/** Change the number of posts on homepage */
add_action( 'pre_get_posts', 'minimum_home_posts' );
function minimum_home_posts( $query ) {
if( $query->is_main_query() && !is_admin() && is_home () ) {
$query->set( 'posts_per_page', '2' );
}
}`Comments are welcome!
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comJune 18, 2013 at 8:43 am #46529Dan B
ParticipantWorked perfectly. Thanks!
Dan @ ZindaMedia
Marketing, Fundraising and Social Media strategies for non-profits.June 18, 2013 at 9:34 pm #46679Chris Moore
MemberGreat to hear Dan! Glad it helped...
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comAugust 8, 2014 at 1:43 pm #117809giraffeweb
ParticipantBy the way - this worked on the Education theme too. I couldn't get the http://www.studiopress.community/topic/education-theme-homepage-blog-would-like-only-one-category-one-post-to-show/ one to work.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.