How To Use Custom /page/2 Template In WordPress

Yesterday, I was editing the theme of my WordPress and I saw that magazine style of my theme was also appearing on the /page/2 page of the post navigation. It looked horrible in the second page, so I wanted to change all the navigation pages with a different template.

After trying a few codes from around the internet, I found a great snippet for this task. Add following code to your current’s theme’s functions.php file:

function trickspanda_change_on_p2( $template ){
    if( is_front_page() && is_paged() ){
        $template = locate_template(array('index-nation.php','index.php'));
    return $template;

Replace index-nation.php in the above code with your custom index template. If your index-nation.php template is not available, then the code would use index.php template.

Leave a Reply

Your email address will not be published. Required fields are marked *