WordPress分页-添加锚链接 [英] WordPress pagination - Adding an Anchor link

查看:96
本文介绍了WordPress分页-添加锚链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的index.php中有这个锚链接:

I have this anchor link in my index.php:

<a name="blog"></a>

我希望该锚点链接能够正常工作,当单击next_posts_link和previous_posts_link时,它不会一直到达页面顶部.我不知道如何针对WordPress分页进行此操作.

I would like this anchor link to work When next_posts_link and previous_posts_link are clicked on so it doesn't go all the way to the top of the page. I have no idea how to go about doing this for WordPress pagination though.

这是我的分页代码:

<div class="pagenavi">
<?php if( function_exists( 'wp_pagenavi ' ) ) {
wp_pagenavi();
} else {
next_posts_link ('<div class="arrow-back"></div>'); }
previous_posts_link('<div class="arrow-forward"></div>') ; }

推荐答案

解决方案2:

使用jQuery将锚点#blog添加到博客文章中的上一个/下一个链接

Adding anchor tag #blog to the prev/next links in a blogpost using jQuery

<script type="text/javascript">
$(document).ready(function() {
    $('.pagenavi a').each(function(i,a){$(a).attr('href',$(a).attr('href')+'#blog')});
});
</script>

演示: http://jsfiddle.net/mfeldheim/EkMfP/12/

这篇关于WordPress分页-添加锚链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆