• Hello,
    I am looking for a way to have the number of posts on the homepage be different than the number of posts on following or archive pages. I’m using the Canvas theme Magazine template & the first 6 posts are set to show full content. The rest follow in a grid of excerpts. I’d love to find a way to put in a page break after the featured/full content posts, OR limit the # of posts on just the home page. Any suggestions appreciated!
    Thank you,
    Maria

Viewing 1 replies (of 1 total)
  • Hello there,

    The posts query can be modified using pre_get_posts filter. To display 3 posts on your homepage, you can add the following function into your child theme’s functions.php file.

    
    function prefix_limit_homepage_posts( $query ){
    	if ( is_home() ) {
    	  $query->set( 'posts_per_page', 3 );
    	  return;
    	}
    }
    add_action( 'pre_get_posts', 'prefix_limit_homepage_posts', 1 );
    

    If you are not running a child theme, alternatively you can use functionality plugin like Code Snippets.

    Regards,
    Kharis

Viewing 1 replies (of 1 total)
  • The topic ‘Different number of posts on homepage’ is closed to new replies.