I think you have a misunderstanding what the homepage (index page) is in WordPress context. The homepage is the main page of the site, by default, this will be like example.com
, AND any paged page derived from this homepage. So example.com/page/2
is also regarded as the homepage. In short, any page where is_home()
returns true will be a home page.
By default, index.php
will be used for the homepage. home.php
will be used, if available, for the blogpage, if set, when a static front page is set.
If you need page one of the homepage to be quite different styling wise than the other paged pages of the homepage, my best bet would be to create a custom template outside the normal hierarchy, and then use the home_template
filter to include this template whenever page one is viewed of the homepage.
EXAMPLE:
Lets create our custom template and call it index-home.php
. This naming convention is unique and does not exist in normal hierarchy, so we are save here. Now, we just need to include it
add_filter( 'home_template', function ( $template )
{
// Only target page one
if ( is_paged() )
return $template;
// We are on page one of the homepage, lets locate and include our template
$locate_template = locate_template( 'index-home.php' );
if ( !$locate_template )
return $template;
return $locate_template;
});
You can also just modify index.php
and add your custom styling and code for page one in a is_paged()
condition. The only drawback to this might be that index.php
is a fallback to all pages regardless, so this would make index.php
an unmaintainable mess
EXAMPLE:
if ( !is_paged()
&& is_home()
) {
// Add code etc for page one homepage
} else {
// Add code etc for all oher pages
}
Just a final note, the main query would still be executed normally. If you need to alter this, you’ll have to use pre_get_posts
to alter the behavior of the main query