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 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题