• Hi I got the code for next and previous buttons and I have put it in the single.php page it is working fine but when i click on next it is taking me to random next and same with the previous button, I want them to link to next article and previous rather randomly any help please I am very desperate please help
    Here is the code I used
    [Code moderated as per the Forum Rules. Please use the pastebin or post small code snippets between backticks.]

    its working fine all it has to do is next should link to next article and same as previous.

    Regards,
    Ramith.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ramith

    (@ramith)

    Sorry, thanks for advice here is the please I need some help

    Cheers,
    Ramith.

    this is what you need to look at: next and previous links in wordpress

    unless it’s all one post and you’re trying to break it up into chunks, then you need to add in

    <!--nextpage--> at the point you want to break the content.

    Thread Starter ramith

    (@ramith)

    Hi, thanks for your help i have copied the code previously from the page you mentioned, but it is linking to random posts in a category, i want it to link to next post, it needs some modification in the code.

    To make it clear I have multiple posts in a category, the next and previous links are working fine but linking to random posts in the category, but i want them to link to next and previous.

    Eg:
    I have a, b, c, d, e posts when i am viewing post c, clicking on next should show post d similarly previous should show post b, but currently it is showing random posts please I need help

    Thanks in advance

    Cheers,
    Ramith.

    when someone clicks on a category it should take them to the “category archive” page for that category where all the categories are listed.

    if you haven’t figured this out yet, here’s what you need to do:

    <div style="text-align: center;">
    <?php previous_post('&laquo; &laquo; % ','Previous Post','no'); ?> | <?php next_post('% &raquo; &raquo;', 'Next Post', 'no'); ?>
    </div>

    put the above code in your theme’s “single.php” file somewhere above this line of code

    <?php endif; ?>

    that’s the end of the wordpress loop.

    refer back to this page to see what options are available to you with regard to styling and the text that goes into the link.

    if you’ve got multiple posts in a category and your theme is only showing a certain number in an archive you can add in this line of code to “archives.php”

    <p><?php posts_nav_link(); ?></p>

    again, add this somewhere before the loop ends. play about with the positioning of the links in both files to see where they sit best.

    hope that works ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Next and Previous Navigation buttons’ is closed to new replies.