Why The Pagination Doesn’t Work In The Custom Blog Posts Page?

When I customized Twenty Twelve theme for my personal blog, I wanted to create a custom blog posts page template to show the posts in a full-width page, it’s so easy I thought, just did the things step by step.

Copy index.php as a new file, rename it to template-fullwidth-blog.php, add /Template Name: Full-width Blog/ into the file, add the following codes in front of while while (have_posts() ) : the_post();

And then, create a new page with this template, save the page and go to “Settings > Reading”, set the front page to this static page, finished! It’s very easy, isn’t it?

But, I drawn up sharply by an unexpected question, the pagination doesn’t work in the homepage, but it was working properly when it’s not the front page, it was so weird!

I was googling many tutorials and following their methods, but it still no luck. So, I compared those solutions and my codes, finally I found the reason, I missed a very small detail, the trouble is the following codes

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

When the page is the static front page, it should be changed to:

$paged = (get_query_var('page')) ? get_query_var('page') : 1;

do you find the difference? Yes, change get_query_var(‘paged’) to get_query_var(‘page’)