0

I tried different tests to make the home (a blog index, 3 latest posts) page use a different template than it's following generated paginated pages (blog.com/page/2). Essentially what I am trying to do is get my home page looking different with latest posts and the "Next Posts" links to the /page/2 with a different template. I thought this was common but can't seem to get it working.

Test 1:

In Settings->Reading->Homepage Display I set to "Your latest posts". Created a 'home.php' file with has_posts() loop and pagination. is_home() and is_front_page() returns true on both the home page and its following paginated pages.

Test 2:

In Settings->Reading->Homepage Display, I set to "Static Page" and set it to a Page I created in the Pages section. Created a page-home.php template file it reads from. is_home() returns false and is_front_page() returns true on both the home page and its following paginated pages.

Test 3:

The obvious page.php template file didn't work.

1

You can use this:

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

$paged will have the value 1 in you are or the first page or the value of respective pagination page number.

Depending on this you can call get_template_part() to load the desired template for the page.

Let me know if this helps.

  • I see where you're going with this but when testing this, and my lack of knowledge of Wordpress, it came out loading the template file along with the home/index page. I ended up putting your code into the home page and just hiding the masthead when it's paged so I'll go ahead and mark this correct. – l3fty Dec 7 '17 at 9:27
  • glad it helped... – Sid Dec 7 '17 at 9:40
-1

https://developer.wordpress.org/files/2014/10/wp-hierarchy.png

should use archive template for this.

  • Hey, sorry I didn't mention but I did try to use that. Archive is different from pagination pages. – l3fty Dec 7 '17 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.