 <p>If you just want to check for their existence and don't need the link, you should use <a href="http://codex.wordpress.org/Function_Reference/get_previous_post" rel="nofollow noreferrer"><code>get_previous_post</code></a> and <a href="http://codex.wordpress.org/Function_Reference/get_next_post" rel="nofollow noreferrer"><code>get_next_post</code>.</a> They don't apply unnecessary formatting that you would ignore if you just use it in an <code>if</code> test. You can still get a link from the post object it returns by passing it to <a href="http://codex.wordpress.org/Function_Reference/get_permalink" rel="nofollow noreferrer"><code>get_permalink</code></a>.</p>