WordPress pagination - Adding an Anchor link(WordPress 分页 - 添加锚链接)
问题描述
我的 index.php 中有这个锚链接:
我希望此锚链接在单击 next_posts_link 和 previous_posts_link 时起作用,因此它不会一直到达页面顶部.不过,我不知道如何为 WordPress 分页执行此操作.
这是我的分页代码:
<?php if(function_exists('wp_pagenavi')){wp_pagenavi();} 别的 {next_posts_link ('<div class="arrow-back"></div>');}previous_posts_link('<div class="arrow-forward"></div>') ;} 解决方案 解决方案 2:
使用 jQuery 将锚标记 #blog 添加到博客文章中的上一个/下一个链接
演示:http://jsfiddle.net/mfeldheim/EkMfP/12/
I have this anchor link in my index.php:
<a name="blog"></a>
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.
Here is my code for the pagination:
<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>') ; }
解决方案 Solution 2:
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>
Demo:
http://jsfiddle.net/mfeldheim/EkMfP/12/
这篇关于WordPress 分页 - 添加锚链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WordPress 分页 - 添加锚链接


- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01