• 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

Eleven40 theme: How to set a different loop for the homeopage?

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 › Eleven40 theme: How to set a different loop for the homeopage?

This topic is: resolved

Tagged: custom homepage, Eleven40, loop, pagination

  • This topic has 12 replies, 3 voices, and was last updated 11 years, 8 months ago by winnydejong.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • August 14, 2013 at 8:40 am #56305
    winnydejong
    Member

    Hi,

    I'd like to set a different loop for the homepage. I use the Eleven40 theme. I'd like the homepage to show the 5 latest blogposts: 1 featured and 4 posts in a grid. I figured the best way to do this would be by adding another loop - since I want all other (archive, categories, search) pages to show the latest 10 blogposts.

    Since I'm a WordPress newbie I can use all help I can get. Hopefully you have an idea how exactly to do this... Thanks in advance!

    Best regards, Winny

    August 14, 2013 at 11:07 am #56344
    Holli
    Member

    I think you're saying you want to limit the number of posts to 5 on the home page. If that's correct, then go into the home.php file in your child theme and add the posts_per_page argument to the existing grid loop array like below:

    function eleven40_grid_loop_helper() {
    
    	if ( function_exists( 'genesis_grid_loop' ) ) {
    		genesis_grid_loop( array(
    			'features'				=> 1,
    			'feature_image_size'	=> 0,
    			'feature_image_class' 	=> 'alignleft post-image',
    			'feature_content_limit' => 0,
    			'grid_image_size'		=> 'grid-featured',
    			'grid_image_class'		=> 'grid-featured',
    			'grid_content_limit' 	=> 250,
    			'posts_per_page'            => 5,
    			'more'					=> __( '[Continue reading]', 'eleven40' ),
    		) );
    	} else {
    		genesis_standard_loop();
    	}
    
    }
    August 14, 2013 at 4:57 pm #56426
    winnydejong
    Member

    Thanks for your suggestion Holli - unfortunately though, it doesn't seem to work... Any ideas?

    August 14, 2013 at 9:08 pm #56448
    Holli
    Member

    Looks like it's changed for 2.0. Sorry about that. You can add this to the bottom of your functions.php file in your theme, and it should work. It will only the limit the posts to 5 on the home page.

    //* Change the number of posts showing in the grid on the homepage
    add_action( 'pre_get_posts', 'eleven40_change_num_posts_in_grid' );
    function eleven40_change_num_posts_in_grid( $query ) {
    	global $wp_the_query;
    		if( $query->is_main_query() && is_home() ) {
    			$query->set( 'posts_per_page', '5' );
    		}
    }
    August 15, 2013 at 1:39 am #56477
    winnydejong
    Member

    It works great - thanks Holli! Is there any way to limit this to the frontpage?

    August 15, 2013 at 2:29 pm #56649
    Holli
    Member

    That should limit it to your home page if you haven't changed any settings in the theme. If you send me the link to your site, I can take a quick look at it.

    August 15, 2013 at 2:44 pm #56655
    Brad Dalton
    Participant

    Great solution which doesn't get over ridden by the default WordPress Reading Settings so your archives aren't effected.

    Also uses the is_home() conditional tag so only effects the home page


    Tutorials for StudioPress Themes.

    August 16, 2013 at 2:27 am #56740
    winnydejong
    Member

    Actually when I start using the code Holli sent me, it also limited the number of posts on pages 2, 3, etc. instead of only on the frontpage. After some research I came up with this, and now only the frontpage shows 5, all other pages show 10 posts:

    //* Limit the frontpage to only showing latest 5 posts - all other pages show 10
    function frontpage_custom_post_count(&$query)
    {
        // show specific number of posts on frontpage
        $frontpagePostsCount = 5;
        if (is_front_page() and !is_paged()) {
            $query->query_vars['posts_per_page'] = $frontpagePostsCount;
        }
        // show configured posts on the rest of pages, offsetting the ones showed on frontpage
        if (is_front_page() and is_paged()) {
            $posts_per_page = isset($query->query_vars['posts_per_page']) ? $query->query_vars['posts_per_page'] : get_option('posts_per_page');
            $query->query_vars['offset'] = (($query->query_vars['paged'] - 2) * $posts_per_page) + $frontpagePostsCount;
        }
    }
    add_action('pre_get_posts', 'frontpage_custom_post_count');
    August 16, 2013 at 4:27 am #56773
    Brad Dalton
    Participant

    You could set that in the WordPress Reading Settings and then use this code which only uses 1 query:

    This code displays 5 on the home page and the same number as your WordPress Reading Settings on paged archives.


    Tutorials for StudioPress Themes.

    August 16, 2013 at 3:05 pm #56900
    winnydejong
    Member

    Thanks Brad for cleaning up the code 🙂 Works just great!

    August 17, 2013 at 12:57 am #56999
    winnydejong
    Member

    Hi!

    Do you know how to change my pagination accordingly. At the homepage (with only 5 posts) you'll see page 1, 2, ... and 27 - while there is no page 27 since all other pages show 10 posts. When you're on the second page - which displays 10 posts - you'll see page 1, 2, ... and 14. Which is correct. This problem definitly has to do with changing the number of posts on the frontpage...

    Any idea how to show the correct last pagenumber at the frontpage? Thanks in advance!!

    August 17, 2013 at 3:28 am #57012
    Brad Dalton
    Participant

    Link to your site please.


    Tutorials for StudioPress Themes.

    August 29, 2013 at 12:15 am #59439
    winnydejong
    Member

    Made another topic for the pagination thing - http://www.studiopress.community/topic/pagination-how-to-fix-and-add-to-eleven40-pro/, including the link to my site. Any idea how to fix the pagination on the frontpage?

    And any idea how to include the same style pagination on another page?

    Thanks, Winny

  • Author
    Posts
Viewing 13 posts - 1 through 13 (of 13 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

© 2025 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