You could use different code. As an example, this modified code from the Twenty Fourteen parent theme which i tested on other themes works well.
Add this to a new file named template-tags.php
<?php
if ( ! function_exists( 'wpsites_post_nav' ) ) :
function wpsites_post_nav() {
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<div class="nav-links">
<?php
previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'wpsites' ) );
next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'wpsites' ) );
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
Creates a template tag which you can use in a custom function or directly in your single.php file:
Child themes functions.php file
require_once( get_stylesheet_directory() . '/template-tags.php' );
Alternatively – Parent themes functions.php file
require get_template_directory() . '/template-tags.php' ;
Single.php template tag
<?php wpsites_post_nav(); ?>