Opened 3 years ago
Closed 3 years ago
#14328 closed defect (bug) (worksforme)
next page doesn't work when using a template page for front page
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | 3.0 |
| Severity: | normal | Keywords: | 2nd-opinion |
| Cc: | michael@… |
Description (last modified by scribu)
Steps to reproduce
1) use the TwentyTen theme
2) create a template using the 'Page of Posts' example from http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates.
3) create some post with a category - more than a page worth
4) create a page called 'MyTest' and assign it the 'PageofPosts' template
5) add a custom field 'category' and the name of your category
6) test it out, it will go to the second page with no problem. If you look at the link you will see: http://yourdomain.com/?page_id=50&paged=2 (the 50 is my page id)
7) go to dashboard->settings->reading and change 'Front Page Displays' to 'a static page' and set the Front Page to MyTest
8) go view the page and try to go to the next page.
What happens is that the first page is fine, but when you try to go to the next page, the link is http://yourdomain.com/?paged=2 and the index.php is loaded, not the page you specified.
Change History (6)
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Resolution invalid deleted
- Status changed from closed to reopened
It seems to me that that is inconsistant.
Lets say I have a page template that I set as the front page and it contains The LOOP, and it does 'X' to every post. If I set the 'Blog pages show at most' to 10, then 10 posts will show "X'. If I change the 'Blog pages show at most' to 5, then I will see "X' on the first 5 posts, but when you go to the next page "X" will not happen. This is inconsistent.
Even more the point, if I have two pages in my site and used the same template for both and set one as the front page, what is seen on both pages should be the same. If it is different then - in my mind - there is a bug.
If you allow the front page to be set to a page with a template, then on pagination, you still have use that template.
Replying to scribu:
That's the correct behaviour: the 'Page of Posts' template is only loaded for the front page, not for subsequent paged archives.
You should use home.php if you want that behaviour.
- Cc michael@… added
- Component changed from General to Template
- Keywords 2nd-opinion added; template front page pagination removed
I have encountered this problem as well. I'm not sure why, but get_query_var( 'paged' ) always seems to return an empty value where is_front_page() returns true. I believe that this is a bug as well.
@juggledad - You can use the following code in your page template to allow the proper value to be applied to the $paged global.
global $paged;
$paged = get_query_var( 'paged' );
if( is_front_page() ) {
$paged = get_query_var( 'page' );
}

That's the correct behaviour: the 'Page of Posts' template is only loaded for the front page, not for subsequent paged archives.
You should use home.php if you want that behaviour.