doujiang1001 2014-12-30 20:54
浏览 45
已采纳

设置页面滚动“get_next_posts_link”?

I currently am developing a custom Wordpress theme. The page is set up in a single page vertically scrolling format. At one point in the theme there is a blogroll with the option to view older posts. Clicking to view older posts refreshes the page & brings the user back to the top, I want to user to remain in place so that upon clicking "View Older Posts" the posts are refreshed and the user is still at the same fixed scroll area instead of being bumped back to the top.

Is there a possible way to use Jquery to bring the next posts in? I thought about editing the "get_next_post_link" function in link-template.php but I'm not sure what javascript to use or how to modify the code to work:

function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
    return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy );
}

I am using a modified version of this theme:

http://www.andersnoren.se/themes/fukasawa/

</div>
  • 写回答

1条回答 默认 最新

  • duanpo2813 2014-12-31 03:40
    关注

    It looks like the system in the facebook or twitter. First, you should add a pointer div element. And when click 'page 2' create query in new page template same as:

    $page=$_GET['paged']; // page 2 to get param
    $showposts=10;
    $offset=($page-1)*$showposts;
    query_posts('offset='.$offset.'&showposts='.$showposts);
    
    while(have_posts()):
       the_post();
       // ...
    endwhile;
    

    And add button click event with jQuery:

    $(".pagenavi li a").click(function(){
        var new_page = $(this).attr("href");
    
        $("#ajax-area").html("LOADING");
        $("#ajax-area").append(new_page);
    return false;
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟