• Hi, like may I’m coming over from MT. I couldn’t find a relevant query here already but if there is I’m sorry and could you point me in the right direction.
    I currently have, on MT, individual pages for each post and a link at the top of these to the next and previous posts at the top of the page.
    I don’t know anything about php and I’m a little lost about how it holds WP together. In MT I have templates for every different type of page I have whereas WP does weird and wonderful things with the just the index. As a result I don’t know where to add the tags to get what I want. Any help much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Depending on your design, the place right before the body of the post would be at the very beginning of <div id="content">
    To insert the links for previous/next post, insert the following code:
    <?php next_post() ?>
    Parameters (from WP Docs):
    * format string for the link (default is “%”, where % is replaced with the title of the next post)
    * text to display to announce the link (default is “next post: “)
    * “yes” or “no”: display the title of the post, or no (default is “yes”)
    * “yes” or “no”: display a link to the next post only if the next post is in the same category (default is “no”)
    * number: which next post ? If you make it ‘2’, the 2nd next post is linked instead of the 1st next one (default is “1”, which means first next post)
    For instance, inserting
    <?php next_post("%","Next post","no","no","1"); ?>
    would show a link to the next post. The link would simply read “Next post” (no title of the next post), and it would show the link whether or not the next post were in the same category.
    The syntax for <?php previous_post() ?> is the same, just put type in the whole thing twice (once with previous_post, once with next_post).

    Thread Starter foolfillment

    (@foolfillment)

    Thanks for the suggestions but I’m not sure I was as clear as I should have been, I wanted to be able to have links to the next/previous posts at the top of individual post pages but not show up on the main page or monthly/category archives.
    I think I’m going to leave it for a while and get everything else running properly before I tackle this again, unless anyone has any easy suggestions.
    Thanks again.

    The only ‘easy’ solution I can think of off the top of my head would then be to place the code above in your wp-comments.php file (assuming you’re not using pop-ups) – of course, that would place the previous/next links underneath your post, not above it, but other than that I’m not PHP- or WP-savvy enough to give you much advice…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘previous_post above the body of the post’ is closed to new replies.