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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?