• aintholly

    (@aintholly)


    I think I’ve found where the template gets the next/previous post links for a single post. In the main index, there’s this code:

    <?php locate_template( array( 'template-parts/loop-nav.php' ), true ); // Loads the template-parts/loop-nav.php template. ?>

    This places “? Previous Post:” at the bottom, under the comment section. I’d like to move this to just below the post, before the comment section. I’d also like it to repeat at the top of the post so that I don’t have to scroll all the way to the bottom to click next or previous when it’s a long post.

    I thought I could paste the text above before <?php the_post(); // Loads the post data. ?> and then again just before <?php comments_template( '', true ); // Loads the comments.php template. ?> However, the next/previous post link is processed only once. The links are produced at the top-most location and then do not appear in the rest of the locations where I’ve included that code.

    Is there a different method to make these links appear anywhere on the page I want them?

Viewing 1 replies (of 1 total)
  • Thread Starter aintholly

    (@aintholly)

    Replying to my own post, I think I understand why it was displaying only once. Now I’m using
    <?php locate_template( array( 'template-parts/loop-nav.php' ), true ); // Loads the template-parts/loop-nav.php template. ?>
    the first place I want to see the next/previous post, and then
    <?php get_template_part( 'template-parts/loop', 'nav' ); ?>
    the next time I want to see it on the page. If there’s a better way, I’d still like to hear, but it appears to be working for now.

Viewing 1 replies (of 1 total)
  • The topic ‘Add next/previous entry to the top of the post’ is closed to new replies.