WordPress.org

Ready to get started?Download WordPress

Forums

Previous Post Permalink on Home Page with Single Post (5 posts)

  1. Douglas Karr
    Member
    Posted 7 years ago #

    I would like to set up a single post PER page with a previous post permalink on each page. I don't have any problem getting one link per page, but previous_post doesn't work on the home page. I've tried a number of queries as well... all to no avail.

    The key here is getting the Permalink. I have gotten the Page 2 link, but I don't want that. I need the permalink for the second page, which is also the second post.

    Thanks!

  2. TheKak
    Member
    Posted 7 years ago #

    I'm also in the same boat, trying to get the HOMEPAGE to display the previous permalink page... for some reason it won't do anything. Help would be great on this, thanks!

  3. Kafkaesqui

    Posted 7 years ago #

    Some template tags work only under certain query-types. next_post() and previous_post() are examples of this, as they only function on single post pages. However, you can reset the WP_Query object's is_single property to *fool* WordPress into seeing your home page as a single post page (albeit temporarily in the example below) so it will display the previous post link:

    <?php
    $wp_query->is_single = true;
    previous_post();
    $wp_query->is_single = false;
    ?>

  4. TheKak
    Member
    Posted 7 years ago #

    Oh so lovely, thanks!

  5. dannybcastillo
    Member
    Posted 7 years ago #

    Can somebody tell me why this won't work.

    <?php
    $wp_query->is_single = true;
    previous_post_link('%link', false, '2 and 3 and 4 and 5 and 6 and 7');
    $wp_query->is_single = false;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic