Focus on cloud service provider activities
Notes on website operation and maintenance

Add Previous Next button to WordPress single page article

Considering the internal link of WordPress SEO, Lao Zuo (laozuo. org) needs to have an internal link in each article. For example, we need to add the link export of the previous article and the next article in each article.

First, we declare the variables of the previous page and the next page:

 <?php $previous = get_previous_post(); $next = get_next_post(); ?>

Then, add the following code snippets in the single.php file of the topic to display them in the article:

 <?php if ( get_previous_post() ) {?> <a href="<?php echo get_the_permalink($previous) ?>"> <img src="<?php echo get_the_post_thumbnail_url($previous) ?>" alt=""> <div> <h3> <? php echo get_the_title($previous) ?></ h3> <p> PREV</p> </div> </a> <?php }?> <?php if ( get_next_post() ) {?> <a href="<?php echo get_the_permalink($next) ?>"> <img src="<?php echo get_the_post_thumbnail_url($next) ?>" alt=""> <div> <h3> <? php echo get_the_title($next) ?></ h3> <p>Next</p> </div> </a> <?php }?>

 

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Add Previous Next button to WordPress single page article