previous_post_link() next_post_link() arrow position

How can I make the arrow as part of the link please?

<?php next_post_link('%link &rarr;'); ?>

The output of above will be | <a href="nextPostLink">NextPostTitle<a> arrow |

Related posts

Leave a Reply

1 comment

  1. As the documentation for next_post_link states, the link parameter is where the actual text of the %link placeholder goes. The format parameter is the whole text, where %link is unpacked from the second link parameter. Solution:

    next_post_link( '%link', '%title &rarr;' );
    

    Expected output: <a href="...">Title &rarr;</a>

    Something like this, on the other hand:

    next_post_link( 'Over to %link now!', '-- %title --' );
    

    …will result in: Over to <a href="...">--- Title ---</a> now!

    See how these are unpacked?