<?php

if ( ! function_exists( 'motivate_post_nav' ) ) :
/**
 * Display navigation to next/previous post
 */
function motivate_post_nav() {
  // Don't print empty markup if there's nowhere to navigate.
  $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="at-postnav" role="navigation">
    <h1 class="screen-reader-text" style="display: none;"><?php esc_html_e( 'Post navigation', 'motivate' ); ?></h1>
    <div class="at-postnav__links">
      <?php
        previous_post_link( '%link', wp_kses_post( '<span>Previous Post</span>', 'motivate' ) );
        next_post_link( '%link', wp_kses_post( '<span class="meta-nav">Next Post</span>', 'motivate' ) );
      ?>
    </div><!-- .nav-links -->
  </nav><!-- .navigation -->
  <?php
}
endif;