[resolved] Previous / Next Post, Use a Different Template (5 posts)

  1. midwestkel
    Posted 7 years ago #

    Hey I want to use a certain template when you first land on the site and when you click home then after that use a different one.

    So the previous post and next post links on the bottom of the home page use the same home.php template it looks like. I would like to use a different template when you click those links.

  2. SimonJ
    Posted 7 years ago #


    You could use your actual home.php, or index.php as a switch with conditional tags to call different template files.

    You need three files :

    1 - home.php : you will use this file as a switch.

    2 - home_normal.php : the "real" home template file

    3 - home_paged.php : the template file to use when you browse next and previous links...


    1 - Copy the content from your actual home.php in a file named home_normal.php.

    2 - In hour home.php, you use a conditional tag to include a specific template file when the home page is "paged" :

    if (is_paged()){include (TEMPLATEPATH . '/home_paged.php');
    else { include (TEMPLATEPATH . '/home_normal.php');

    This code tells to wordpress : if we are browsing previous and next posts page, open home_paged.php... Else, open home_normal.php...

    3 - Make a file home_paged.php and use it to build the template you would like when you browse previous links...


    Of course, you could use conditionnal tags in only one "home.php", but I find this technique cleaner and it's more simple to make some modification : I f you want to change your normal home layout, you edit home_normal.php... If you want to edit the "paged" layout, you edit home_paged.php...


  3. midwestkel
    Posted 7 years ago #

    That worked, easier than I thought it would be, thanks!

  4. jayo
    Posted 7 years ago #

    I used this method as well. Worked like a charm. Thanks so much.

  5. etageneuf
    Posted 7 years ago #

    Great SimonJ ... I've made the modification you told us.

    But i can't figure how to choose the one of the two files (home_paged.php or home-normal.php) which will be the first seen when checking my domain name ...

    It would so cool to read any explanations about this point ...
    Thank you so much for any further details !

Topic Closed

This topic has been closed to new replies.

About this Topic