<?php previous_post_link('%link','<<') ?>
<?php next_post_link('%link','>>') ?>
但是这样的链接没有带title属性,不利于SEO,我们可以通过以下方法修改。
在模板里面找到上面的那两句代码,将其替换为如下代码即可:
<?php
$prev_post = get_previous_post();
if (!empty( $prev_post )): ?>
<a title="<?php echo $prev_post->post_title; ?>" href="<?php echo get_permalink( $prev_post->ID ); ?>" rel="external nofollow" ><?php echo $prev_post->post_title; ?></a>
<?php endif; ?>
<?php
$next_post = get_next_post();
if (!empty( $next_post )): ?>
<a title="<?php echo $next_post->post_title; ?>" href="<?php echo get_permalink( $next_post->ID ); ?>" rel="external nofollow" ><?php echo $next_post->post_title; ?></a>
<?php endif; ?>
然后清除一下缓存,就可以看到上下篇文章的链接已经带了title属性了!