• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How can I limiting the number of blog posts only on the homepage of Minimum?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How can I limiting the number of blog posts only on the homepage of Minimum?

This topic is: resolved

Tagged: Genesis Grid Loop, minimum, posts

  • This topic has 4 replies, 3 voices, and was last updated 8 years, 7 months ago by giraffeweb.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 30, 2013 at 11:23 am #43246
    Chris Moore
    Member

    Hello,

    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!


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    http://moorecreativeideas.com
    May 30, 2013 at 11:39 am #43248
    Chris Moore
    Member

    Well, 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.com

    June 18, 2013 at 8:43 am #46529
    Dan B
    Member

    Worked perfectly. Thanks!


    Dan @ ZindaMedia
    Marketing, Fundraising and Social Media strategies for non-profits.

    June 18, 2013 at 9:34 pm #46679
    Chris Moore
    Member

    Great to hear Dan! Glad it helped...


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    August 8, 2014 at 1:43 pm #117809
    giraffeweb
    Participant

    By 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.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble