0

My homepage has 1 featured post, followed by 4 posts stacked 2 on 2, like this:

enter image description here

The featured post is only shown on the first page so the second page shows the older posts stacked 2 by 2 as above.

However, I'd like to be able to change the layout on the second page, showing the posts in full width and length. Any way to do this?

tl;dr = How can I make the second page look different from the first page?

1

2 Answers 2

2

To load override WordPress' choice of template you can use template_include filter and then use the locate_template to return the the template file path (if it finds it).

The file-name passed to locate_template must be the name of the template file name (which should be in you theme/child-theme directory).

//Loads template customtemplate.php from your theme folder on page 2+ of the 'main page'
function my_second_main_template($template){
    if (is_home() && is_paged()){
         $alternate_template = locate_template( 'customtemplate.php');
         if(!empty($alternate_template))
              $template =$alternate_template;
    }
    return $template;
}
add_filter('template_include','my_second_main_template');
2
  • Seems to do the trick. I've made a new template and going to the second does use that new layout but it also repeat the body from the front page after the custom template.... Commented Feb 25, 2012 at 18:00
  • @Jannemans I've updated my code, see if that fixes it :D Commented Feb 25, 2012 at 18:22
0

If I understand your question correctly, I would make a separate template for home.php and a separate template for archive.php to achieve this.

1
  • This won't work - page 2 of the main page will still use the same template as the main page. Commented Feb 25, 2012 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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