I’m trying to achieve a specific layout which results in 7 posts on the home page, and 9 posts on subsequent pages – 2, 3, 4 etc. In addition to adding some code to functions.php I’ve been told I need to add the following code just before the pagination function:
global $wp_query;
// Needed for first page only
if ( ! $wp_query->is_paged ) {
$all_posts_except_fp = ( $wp_query->found_posts - 7 ); // Get us the found posts except those on first page
$wp_query->max_num_pages = ceil( $all_posts_except_fp / 9 ) + 1; // + 1 the first page we have containing 7 posts
}
Which file would I add this to, or will I need to create a custom home.php template in the child theme?
– This code you place at Inside Content Container Hook (GP Hooks)
<?php global $wp_query;
if ( ! $wp_query->is_paged ) {
$all_posts_except_fp = ( $wp_query->found_posts - 7 ); // Get us the found posts except those on first page
$wp_query->max_num_pages = ceil( $all_posts_except_fp / 9 ) + 1; // + 1 the first page we have containing 7 posts
} ?>