How to add next and previous post in WordPress?

How to add next and previous post in WordPress? Code for next and previous post in single page, Code for next & previous post in WordPress, PHP code for next & previous post in WordPress. You want to add next and previous post in your single post page, just follow my instruction, from here you can easily get your solution. Here we work single.php and style.css file. Now you open this two file and copy below code and paste to your file. Now copy below code and paste your single.php file where you see your next and previous post.


<div class="next-previous-post">

<?php $BRprevPost = get_previous_post(true);
if($BRprevPost) {
$args = array(
'posts_per_page' => 1,
'include' => $BRprevPost->ID
);
$BRprevPost = get_posts($args);
foreach ($BRprevPost as $post) {
setup_postdata($post);
?>
<?php $embaded_link= get_post_meta($post->ID, 'embaded_link', true); ?>

<div class="brnewstheme-previous-post">
<h3 class="sidebar-title"><a class="previous-link" href="<?php the_permalink(); ?>">&laquo; Previous Article</a></h3>
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbs">
<div class="img-box">
<img src="<?php the_post_thumbnail_url('medium'); ?>"/>
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php the_post_thumbnail_url(); ?>" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>

</div>
</div>
</div>
<?php elseif((meta_options('pagebg') !='' || meta_options('embaded_link')!='')): ?>
<div class="video-post">
<?php echo emabdedTheLink(meta_options('embaded_link'),'130','85'); //with width(1000,500);?>
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php echo $embaded_link; ?>" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>

</div>
</div>
<?php else : ?>
<div class="post-thumbs">
<div class="img-box">
<img src="<?php bloginfo('template_url'); ?>/images/it-helps-bd.jpg" alt="" />
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php echo bloginfo('template_url'); ?>/images/it-helps-bd.jpg" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>
</div>
</div>
</div>
<?php endif; ?>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<div class="meta-post">
<div class="meta-data date"><?php the_time('F j, Y') ?></div>
<div class="meta-data post-author"><?php the_author(); ?></div>

</div>
</div>
<?php
wp_reset_postdata();
}
}

$BRnextPost = get_next_post(true);
if($BRnextPost) {
$args = array(
'posts_per_page' => 1,
'include' => $BRnextPost->ID
);
$BRnextPost = get_posts($args);
foreach ($BRnextPost as $post) {
setup_postdata($post);
?>
<?php $embaded_link= get_post_meta($post->ID, 'embaded_link', true); ?>

<div class="brnewstheme-next-post">
<h3 class="sidebar-title"><a class="next-link" href="<?php the_permalink(); ?>">Next Article &raquo;</a></h3>
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbs">
<div class="img-box">
<img src="<?php the_post_thumbnail_url('medium'); ?>"/>
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php the_post_thumbnail_url(); ?>" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>

</div>
</div>
</div>
<?php elseif((meta_options('pagebg') !='' || meta_options('embaded_link')!='')): ?>
<div class="video-post">
<?php echo emabdedTheLink(meta_options('embaded_link'),'130','85'); //with width(1000,500);?>
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php echo $embaded_link; ?>" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>

</div>
</div>
<?php else : ?>
<div class="post-thumbs">
<div class="img-box">
<img src="<?php bloginfo('template_url'); ?>/images/it-helps-bd.jpg" alt="" />
<div class="ovrly"></div>
<div class="buttons">
<a class="fa fa-search info" href="<?php echo bloginfo('template_url'); ?>/images/it-helps-bd.jpg" rel="prettyPhoto" title="<?php the_title_attribute(); ?>"></a>
</div>
</div>
</div>
<?php endif; ?>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<div class="meta-post">
<div class="meta-data date"><?php the_time('F j, Y') ?></div>
<div class="meta-data post-author"><?php the_author(); ?></div>

</div>
</div>
<?php
wp_reset_postdata();
}
}
?>
</div>

Now you open your style.css file and copy below code and paste to your style.css file.


/* PREVIOUS POST AND NEXT POST IN SINGLE.PHP*/
.next-previous-post{ margin-top:20px;}
.brnewstheme-previous-post, .brnewstheme-next-post{ display:inline-block; width:48%; margin-right:3%; margin-bottom:20px;}
.brnewstheme-next-post{ margin-right:0%;}
.brnewstheme-previous-post .post-thumbs .img-box, .brnewstheme-next-post .post-thumbs .img-box, .brnewstheme-next-post .video-post{ width:30%; max-width:100%;}
.next-previous-post .post-thumbs .buttons .fa, .brnewstheme-next-post .post-thumbs .buttons .fa, .next-previous-post .video-post .buttons .fa{ line-height:30px; width:30px; height:30px;}

54 Responses to “How to add next and previous post in WordPress?”

  1. Mersin parça eşya taşıma hizmetini her zaman vermek için hazır dayız parça eşya taşıma da gücümüzün yetmediği başınızın sıkıştığı yerde bizim öncü firmalarımız gelir sizler için her zaman en iyi kaliteyi sunmaya çalışıyoruz. Mersin parça eşya taşıma fiyatları ve parsiyel taşımacılık için en uygun fiyat politikaları sizleri bekliyor.

  2. viz says:

    Say, you got a nice blog post.Thanks Again.

  3. viz says:

    A big thank you for your blog article.Thanks Again. Want more.

  4. I have wanted to post something like this on one of my blogs and this has given me an idea. Thank you.

  5. 19 yas porno says:

    Say, you got a nice blog post.Thanks Again.

  6. Great blog here! Also your website loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my website loaded up as fast as yours lol

  7. I cannot thank you enough for the blog post.Really looking forward to read more. Awesome.

  8. Forrest says:

    wonderful submit, very informative. I ponder why the opposite specialists oof this sector don’t understand
    this. You should continue your writing. I am sure, you have a huge readers’ base already!

  9. A big thank you for your blog article.Thanks Again. Want more.

  10. I cannot thank you enough for the post.Really looking forward to read more. Cool.

  11. Thank you for your blog article.Really looking forward to read more. Will read on…

  12. google says:

    I cannot thank you enough for the blog post.Really looking forward to read more. Awesome.

  13. film izlet says:

    Thank you for your blog article.Really looking forward to read more. Will read on…

  14. film izlet says:

    Say, you got a nice blog post.Thanks Again.

  15. Thank you for your blog article.Really looking forward to read more. Will read on…

  16. This is a really interesting concept. I have never thought of how many different connections that I have to photography. As a wedding and portrait photographer, I studied photojournalism at the University of Florida. I also make prints and I collect a few camera memorabilia here and there but I have never considered how many different ties that I have to photography.

  17. fuck says:

    I appreciate you sharing this blog article. Much obliged.

  18. fuck google says:

    Say, you got a nice blog post.Thanks Again.

  19. Firmamız tarafından üretimini yapmış olduğumuz tüm cami halılarında için birbirinden farklı renk seçenekleri, motif ve iplik çeşitleri ile pek çok cami halısı modelleri yapılmaktadır. Website > https://camihalisi.info/

  20. fuck child says:

    I appreciate you sharing this blog article. Much obliged.

  21. fuck google says:

    A big thank you for your blog article.Thanks Again. Want more.

  22. fuck child says:

    Thank you for your blog article.Really looking forward to read more. Will read on…

  23. The other day, while I was at work, my cousin stole my iPad and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is completely off topic but I had to share it with someone!

  24. Jonas Napoli says:

    One more issue is really that video gaming became one of the all-time greatest forms of excitement for people of every age group. Kids play video games, and also adults do, too. The particular XBox 360 is amongst the favorite video games systems for those who love to have a lot of games available to them, and who like to relax and play live with other individuals all over the world. Many thanks for sharing your thinking.

  25. A big thank you for your blog article.Thanks Again. Want more.

  26. child porno says:

    A big thank you for your blog article.Thanks Again. Want more.

  27. porno cocuk says:

    I cannot thank you enough for the post.Really looking forward to read more. Cool.

  28. cocuk porno says:

    I cannot thank you enough for the blog post.Really looking forward to read more. Awesome.

  29. cocuk porno says:

    I appreciate you sharing this blog article. Much obliged.

  30. recycling says:

    This site certainly has alll the information and facts I needed about this
    subject and didn’t know who to ask.

  31. junk removal says:

    Hi, for all time i used to check blog posts here early in the dawn, for the reason that i likee tto gain knowledge of more and more.

  32. Bez çanta satışı toptan ve perakende amerikan bezinden imalat yapılmış bez çantalar promosyon çanta. https://uniwaybezcanta.com/bez-canta/ #BezÇanta Bez Çanta ürünlerinde online satış GittiGidiyor’da! Bez Çanta modelleri, Bez Çanta çeşitleri ve markalarını uygun fiyatları ile satın alın.

  33. Whoa! This blog looks just like my old one! It’s on a entirely different subjecct but it has pretty
    much the same pawge layout and design. Excellent cholice of colors!

  34. It is nott myy first time to visiot this website, i am
    browsing this weeb page dailly and get nice facts
    from here daily.

  35. pornom says:

    Thank you for your blog article.Really looking forward to read more. Will read on…

  36. pornom says:

    Say, you got a nice blog post.Thanks Again.

  37. Web Tasarım, Grimor, kuruluşundan beri sizlere özel tasarım ve web hizmetleri vermektedir. https://www.pentayazilim.com/web-tasarim/ Web tasarım ihtiyaçlarınız için en doğru adres Grimor.com. Kurumsal web tasarım firması MediaClick İstanbul, SEO ve mobil uyumlu profesyonel web site tasarımları ile web sitesi tasarımı yarışmalarında ödüller almıştır. Profesyonel web tasarım hizmetleri sunan, Biltek Web Tasarım şirketi ile kusursuz bir web sitesi tasarımına sahip olacaksınız. Web Tasarım ajansımız İstanbul’da…

  38. sex izle says:

    I cannot thank you enough for the post.Really looking forward to read more. Cool.

  39. cocuk porno says:

    Thank you for your blog article.Really looking forward to read more. Will read on…

  40. Hosting Games 2018 Yılında Hosting Games İnternet Hizmetleri tarafından kurulmuştur.Kesintisiz ve kaliteli hizmetler vererek müşterilerinin arzularını yerine getirmeye çalışmaktayız,uzman kadromuz ve son teknoloji makinelerimiz ile en iyi hizmeti vermeye çalışmaktayız.Kendine ait alt yapı yatırımı sayesinde her zaman güncel donanımlara sahiptir…!! Website https://hostingames.com/

  41. A big thank you for your blog article.Thanks Again. Want more.

  42. Say, you got a nice blog post.Thanks Again.

  43. Carl Feehan says:

    Hello my friend! I want to say that this article is amazing, nice written and come with almost all important infos. I’d like to look more posts like this .

  44. I cannot thank you enough for the post.Really looking forward to read more. Cool.

  45. Greetings! I’ve been following your weblog for a long time now and finally got the courage to go ahead and give you a shout out from Lubbock Tx! Just wanted to tell you keep up the great work!

  46. BLONDO HOLDINGS is a private investment company incorporated in the United Kingdom. Our team consists of professionals who provide clients and partners with confidence and only best consulting and financial services. Join our company and use a great chance to conquer the trading market and be successful people. Our company, BLONDO HOLDINGS, is engaged in the cryptocurrencies mining and investments in Blockchain technology as one of the most promising technologies of the 21st century, and achieved high results in own activities. We offer 4 different investment plans: STARTER PLAN: 150 Per Cent Weekly (Min: 10 DOLLARS – Max: 49 DOLLARS) (TOTAL RETURN: 150 per cent) /// SILVER PLAN: 200 Per Cent Weekly (MIN: 50 DOLLARS – MAX: 299 DOLLARS) (TOTAL RETURN: 200 per cent) /// GOLD PLAN: 1 per cent Hourly – Duration: 7 Days – (Min 300 – Max 1000) (TOTAL RETURN: 168 per cent) (Withdrawal Anytime) /// PLATINUM PLAN: 5 per cent Daily – Duration: 55 Days – (Min: 500 – Max: 2500) (TOTAL RETURN: 275 per cent) (Withdrawal Anytime)

  47. I appreciate you sharing this blog article. Much obliged.

  48. I cannot thank you enough for the post.Really looking forward to read more. Cool.

  49. google says:

    I appreciate you sharing this blog article. Much obliged.

  50. google says:

    I appreciate you sharing this blog article. Much obliged.

  51. emlak says:

    I cannot thank you enough for the blog post.Really looking forward to read more. Awesome.

  52. are you sex says:

    Thank you for your blog article.Really looking forward to read more. Will read on…

  53. I cannot thank you enough for the post.Really looking forward to read more. Cool.

​Leave a Comment

Comment authors age:




How to Recent Post Show Exclude a Specific Taxonomy?

How to add related post in wordpress?