Some theme post template doesn’t have previous/next post

we can add below code to the single post template:

 

<!--Previous and next Post-->

  <div class="man_nearby_posts row">

    <h2>Other Posts</h2>

    </br>

<?php $prevPost = get_previous_post(true);

if($prevPost) {?>

<div class="nav-box man_nav_previous man_image_bck col-md-6" data-image="<?php echo get_the_post_thumbnail_url( $prevPost->ID, 'medium_large'); ?>" data-color="#292929">




<div class="man_nav_over"></div>

<div class="man_nav_txt">

<span><i class="ti ti-angle-left"></i><?php esc_html_e('Previous','manufacturer'); ?></span> 

<a href="<?php echo esc_url(get_permalink($prevPost->ID)); ?>"><h3><?php echo get_the_title($prevPost->ID); ?></h3></a>

</div>

</div>

<?php }else{ ?>

<div class="nav-box man_nav_previous man_image_bck col-md-6" data-color="#333">

<div class="man_nav_over"></div>

<div class="man_nav_txt">

<h3><?php echo get_the_title($post->ID); ?></h3>

</div>

</div>

<?php } ?>




<?php $nextPost = get_next_post(true);

if($nextPost) { ?>

<div class="nav-box man_nav_next man_image_bck col-md-6" data-image="<?php echo get_the_post_thumbnail_url( $nextPost->ID, 'medium_large'); ?>" data-color="#292929">


<div class="man_nav_over"></div>

<div class="man_nav_txt">

<span><?php esc_html_e('Next','manufacturer'); ?> <i class="ti ti-angle-right"></i></span>

<a href="<?php echo esc_url(get_permalink($nextPost->ID)); ?>"><h3><?php echo get_the_title($nextPost->ID); ?></h3></a>

</div>

</div>

<?php }else{ ?>

<div class="nav-box man_nav_next man_image_bck col-md-6" data-color="#333">

<div class="man_nav_over"></div>

<div class="man_nav_txt">

<h3><?php echo get_the_title($post->ID); ?></h3>

</div>

</div>

<?php } ?>

  </div>

<!--Previous and next Post-->