Forums

Previous and Next Post on same line (7 posts)

  1. jamesaw
    Member
    Posted 1 year ago #

    The theme I am currently using does not have previous and next post built in so I had to add it using this code:

    <p style="text-align: left;"><?php previous_post_link(); ?><p style="text-align: right;"><?php next_post_link(); ?>

    It does work but the next post is on the following line right aligned I want them to be be on the same line.

    Many thanks

  2. vtxyzzy
    Member
    Posted 1 year ago #

    I think this will work:

    <div><span style='float: left;<?php previous_post_link(); ?></span><span style='float: right;'><?php next_post_link(); ?></span></div>

    You may have to put a div after it to clear the floats.

  3. jamesaw
    Member
    Posted 1 year ago #

    Ok let me check.

  4. jamesaw
    Member
    Posted 1 year ago #

    Ok it doesn't work, it removes the previous post and only displays the next post.

  5. jlevan
    Member
    Posted 1 year ago #

    There was a typo in the code above, try this:
    <div><span style='float: left;'><?php previous_post_link(); ?></span><span style='float: right;'><?php next_post_link(); ?></span></div>

    The first opening span tag wasn't closed

  6. vtxyzzy
    Member
    Posted 1 year ago #

    @jlevan, the closing tag is there, but it may not have been copied.

  7. jamesaw
    Member
    Posted 1 year ago #

    That worked perfectly thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic