WordPress翻页链接添加title属性

在你的文章页面添加以下代码,替换掉?php previous_post_link()php next_post_link()函数。

<?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; ?>

发布日期:

所属分类: Wordpress 综合 标签:   


没有相关文章!