WordPress.org

Ready to get started?Download WordPress

Forums

getting pagination to switch from home.php to index.php (3 posts)

  1. photocurio
    Member
    Posted 1 year ago #

    I have a front page with multiple loops on this site: fashioncow.com. The loops are on the home.php template. The last loop is paginated, using Alchymyth's code. This all works well (surprisingly).

    The problem is that I want the Previous Entries link to display page 2 in the index.php template, not the home.php template. I want back pages to display like an archive page, with just one loop, skipping the featured post loops that the front page has.

    Is there a way to tell the pagination function to display the query in a certain template?

  2. photocurio
    Member
    Posted 1 year ago #

    I keep thinking this should be easy. I just want:
    http://fashioncow.com/ to load home.php
    and
    http://fashioncow.com/page/2/ to load index.php

    There should be a way to get WordPress to do this.

  3. photocurio
    Member
    Posted 1 year ago #

    If anyone wants to know the solution to this, its a two part thing. The first part is getting WP to load the correct template. I put a template redirect in the functions.php file. See Change template dynamically. I've been building Wordpess themes for 3 years, pretty much full time, and this is the first I've heard of template redirect. There's always another layer to WordPress.

    And it works perfectly.. except that now pagination is messed up. If I add an offset to the loop's query_posts to account for the front page's featured posts, then pagination disappears. You can't have both pagination and offset in a query_posts loop. You have to choose one or the other.

    Again, some smarter-than-I programmer has a solution (from 2008). It involves yet more functions, and a loop syntax I've never seen before. Its here: How to: Offsets and Paging.

    Finally pagination seems to be working correctly at Fashioncow.

Topic Closed

This topic has been closed to new replies.

About this Topic