WordPress’s posts_nav_link tag accepts a parameter for a separator and performs logic to conditionally display the separator when both prev/next links are present. However, if you want to use separate tags for previous and next post links for more custom control over the style and markup of your links, you lose this convenient conditional separator feature.
There is, of course, a solution to this. Conditional separators (and much more) can be achieved with a handy WP template function called get_adjacent_post. This templating function accepts three parameters: a boolean for whether to fetch posts only in the same category as the current one, a string of category IDs to exclude (if any), and a boolean for whether to retrieve the previous post. If this third parameter is set to true, the previous post is returned. If set to false, the next post is returned. If no post exists in the specified adjacent position, an empty string is returned.
Therefore, if you wished to (for example) have a pipe “|” separating your prev/next links but only when both links are present, your pagination links might resemble the following:
<p class="prev-next"> <?php previous_post_link('%link','Previous'); ?> <?php if ((get_adjacent_post(false, '', false)) && (get_adjacent_post(false, '', true))) echo '|'; ?> <?php next_post_link('%link','Next'); ?> </p>
This function is more powerful and ubiquitous than demonstrated in this snippet alone: you can change the code for the links themselves if you wish. For more information on how to gain fine-grained control over those frustratingly stubborn WordPress nav links, Conditional and custom next/previous post links in WordPress is a great, more detailed article to get you started.