mh_magazine_lite_postnav

The MH Magazine lite mh magazine lite postnav function.

Description

mh_magazine_lite_postnav(); 

Usage

  1. if ( !function_exists( 'mh_magazine_lite_postnav' ) ) { 
  2. require_once '/includes/mh-custom-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = mh_magazine_lite_postnav(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/mh-custom-functions.php  
  1. function mh_magazine_lite_postnav() { 
  2. $mh_magazine_lite_options = mh_magazine_lite_theme_options(); 
  3. if ($mh_magazine_lite_options['post_nav'] === 'enable') { 
  4. global $post; 
  5. $parent_post = get_post($post->post_parent); 
  6. $attachment = is_attachment(); 
  7. $prev_post = get_previous_post(); 
  8. $next_post = get_next_post(); 
  9. if (!empty($prev_post) || !empty($next_post) || $attachment) { 
  10. echo '<nav class="mh-post-nav mh-row clearfix" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">' . "\n"; 
  11. if (!empty($prev_post) || $attachment) { 
  12. echo '<div class="mh-col-1-2 mh-post-nav-item mh-post-nav-prev">' . "\n"; 
  13. if ($attachment) { 
  14. if (wp_attachment_is_image()) { 
  15. $attachments = get_children(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $parent_post->ID)); 
  16. $count = count($attachments); 
  17. if ($count == 1) { 
  18. echo '<a href="' . esc_url(get_permalink($parent_post)) . '">' . '<span>' . esc_html__('Back to article', 'mh-magazine-lite') . '</span>' . '</a>'; 
  19. } else { 
  20. previous_image_link('%link', '<span>' . esc_html__('Previous', 'mh-magazine-lite') . '</span>'); 
  21. } else { 
  22. echo '<a href="' . esc_url(get_permalink($parent_post)) . '">' . '<span>' . esc_html__('Back to article', 'mh-magazine-lite') . '</span>' . '</a>'; 
  23. } else { 
  24. $prev_thumb = get_the_post_thumbnail($prev_post->ID, 'mh-magazine-lite-small'); 
  25. previous_post_link('%link', $prev_thumb . '<span>' . esc_html__('Previous', 'mh-magazine-lite') . '</span>' . '<p>%title</p>'); 
  26. echo '</div>' . "\n"; 
  27. if (!empty($next_post) || $attachment) { 
  28. echo '<div class="mh-col-1-2 mh-post-nav-item mh-post-nav-next">' . "\n"; 
  29. if ($attachment) { 
  30. next_image_link('%link', '<span>' . esc_html__('Next', 'mh-magazine-lite') . '</span>'); 
  31. } else { 
  32. $next_thumb = get_the_post_thumbnail($next_post->ID, 'mh-magazine-lite-small'); 
  33. next_post_link('%link', $next_thumb . '<span>' . esc_html__('Next', 'mh-magazine-lite') . '</span>' . '<p>%title</p>'); 
  34. echo '</div>' . "\n"; 
  35. echo '</nav>' . "\n";