Thanks to s_ha_dum for the tip. I managed to solve it by setting the offset
parameter in the special case of 2nd page onwards for the front page as follows:
function limit_posts_per_home_page()
{
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$first_page_limit = 5;
$limit = get_option('posts_per_page');
if (is_front_page())
{
if ($paged == 1)
{
$limit = $first_page_limit;
}
else
{
$offset = $first_page_limit + (($paged - 2) * $limit);
set_query_var('offset', $offset);
}
}
set_query_var('posts_per_archive_page', $limit);
set_query_var('posts_per_page', $limit);
}
add_filter('pre_get_posts', 'limit_posts_per_home_page');
Related Posts:
- How to use pre_get_posts?
- Jetpack Infinite scroll conflicting with theme’s pre_get_posts custom posts_per_page
- Using pre_get_posts to filter out posts, pagination problem
- Why am I getting a 404 on anything past page 1 of my query?
- Skip first post on Category Archive
- Pagination not working past page 3 on archive page of category
- Changing pagination list class
- How to show a single post on the front page but have normal paging?
- Pagination resolving to first page only
- Pagination of RSS2 feed
- Pre get posts for single post
- List posts based on first letter of posts
- Pagination for sub-pages
- How to implement pagination eg. newer – 3 – 4 – 5 – 6 – 7 – older
- Custom loop pagination issue ( pagination not showing up )
- Paginate tags page
- Category pagination shows same posts
- How to display next and prev pagination links with WP_User_Query?
- Custom taxonomy list and sortby letter pagination problem
- WordPress Pagination not displaying posts after certain page
- add spans and characters into paginate_links
- Show next / previous text (button) all the time
- wordpress Next/Previous post in same category not working
- Pagination difficulty using custom query in genesis-based custom theme
- Placing Ads after every 10th Post with Infinite Scroll
- How to implement pagination in backward way eg. first – 20 – 19 – 18 – … – 3 – 2 – 1 – last
- WordPress Pagination not working, any ideas?
- Next & Previous (Pagination in this case) Not Appearing
- Limit Timber pagination number items
- List all posts by year with pagination
- WordPress wp_link_pages show only next/prev link
- Pass additional parameter in the URL
- Post timeline (pagination with date, not numbers)
- Why do next pages load the same content rather then older articles?
- How to disable pagination (next/previous links) on post type archive?
- Nested Pagination
- Pagination stopped working after assigning custom page template to new page (different slug)
- I want to remove numbers from the_posts_pagination function
- Yoast’s rel=“next” & rel=“prev” tag don’t work on static homepage’s paginated pages
- Using paginate_links() to generate “01, 02, 03, 04” paginations
- Pagination not working on custom page
- 404 when using pagination in a category
- How do I fix this ‘Undefined variable:’ debug message?
- Authors list Pagination : result set from $wpdb->get_results()
- WP-PageNavi on Custom page template not working
- Paginated Archives or Loop by Month
- Pagination Not Working on `WP_Query` Archive Page
- How do I make my pagination work?
- How to use custom previous/next link ?
- How to paginate a list of child pages
- Show content based on page number
- Pagination issue in archive.php
- How to use pagination?
- How to get category/tag in URL for Pagination links?
- Pagination on and tag.php not working
- Include a leading zero in pagination
- Pagination not work on page but work on category
- Can I use paginate_links() to add a pagination list, yet prevent it from inserting links?
- Custom category.php paging shows the same posts
- Pagination Links showing incorrect previous page number
- How to limit page pagination… again
- Conditional pagination li’s
- Paginate Links – Mid Size Less Than 2
- Problem when I try to insert pagination
- Different page template for paginated content?
- tax_query does not work with pagination with custom query (both wp_query and query_posts())
- Pagination for multiple queries merging into one Loop
- paginate_comments_links() not working
- Adding paging to get_posts()
- Can I paginate this get_attachment query?
- WP_Query, Paginate by Custom Field
- How to Show Next-Previous Link Only
- WordPress static home page pagination not working
- How to create a WordPress gallery with pagination
- Broken pagination links on WP 4.9.10 blog pages
- Excluding posts without affecting the number of posts per page
- get_next_posts_page_link adds Inexistent directories
- How to add post page pagination to template part?
- why pagination not working in page template
- 404 page not found on pagination in home page while navigating to next page
- Pagination in Archives
- Only show pagination when post count exceeds show post
- Pagination – linking back to base page – Page 1
- Custom Pagination shows same posts on each page
- Numbered pagination showing all numbers instead of paginated blocks
- Show next and previous page number
- Search pagination link redirecting to a link that doesn’t work with pagination
- Custom Query & Rewritten URL Pagination 404
- Adding pagination to query for custom page
- Main page paginate_links issue
- WordPress creating 404s under blog tags
- Removing template part when not on homepage if / else
- Paginate template name
- WordPress pagination URL posts not load
- How to reduce the number of pages in pagination
- Use cookies in pagination
- foreach pagination
- Always show Next and Previous button in wp_link_pages ?
- paged query leads to 404? [duplicate]
- Pagination only working on index page not on a template page