Guest User

GP Post Navigation Element

a guest
Mar 24th, 2019
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div id="post-nav">
  2.     <?php global $post;
  3.     $prevPost = get_previous_post(false);
  4.         if($prevPost) {
  5.             $args = array(
  6.                 'posts_per_page' => 1,
  7.                 'include' => $prevPost->ID
  8.             );
  9.             $prevPost = get_posts($args);
  10.             foreach ($prevPost as $post) {
  11.                 setup_postdata($post);
  12.     ?>
  13.         <a class="post-previous" href="<?php the_permalink(); ?>">
  14.                 <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.1),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url(); ?>');">
  15.             <div class="post-nav">Previous</div>
  16.             <h3 class="post-nav-title"><?php the_title(); ?></h3>
  17.         </div></a>
  18.     <?php
  19.                 wp_reset_postdata();
  20.             } //end foreach
  21.         } // end if
  22.          
  23.         $nextPost = get_next_post(false);
  24.         if($nextPost) {
  25.             $args = array(
  26.                 'posts_per_page' => 1,
  27.                 'include' => $nextPost->ID
  28.             );
  29.             $nextPost = get_posts($args);
  30.             foreach ($nextPost as $post) {
  31.                 setup_postdata($post);
  32.     ?>
  33.         <a class="post-next" href="<?php the_permalink(); ?>">
  34.         <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.6),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url(); ?>');">
  35.             <h3 class="post-nav-title"><?php the_title(); ?></h3>
  36.             <div class="post-nav">Next</div>                   
  37.         </div></a>
  38.     <?php
  39.                 wp_reset_postdata();
  40.             } //end foreach
  41.         } // end if
  42.     ?>
  43. </div>
RAW Paste Data