我在wordpress中使用ajax加载更多插件,它正在工作无限滚动帖子,现在我想要当新帖子加载时url必须显示为新url
这是我的网页代码:
<?php get_header(); ?>
<?php
$infinite = ot_get_option('infinite_load', 'on');
?>
<div id="infinite-article" data-infinite="<?php echo esc_attr($infinite); ?>" class="<?php echo esc_attr($infinite); ?>">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php
$id = get_the_ID();
$format = get_post_format();
if ($format == 'video' ){
$post_style = get_post_meta($id, 'video-post-detail-style', true) ? get_post_meta($id, 'video-post-detail-style', true) : 'style1';
get_template_part( 'inc/post-detail-styles/'.$format.'-'.$post_style );
} else if ($format == 'gallery' ){
$post_style = get_post_meta($id, 'gallery-post-detail-style', true) ? get_post_meta($id, 'gallery-post-detail-style', true) : 'style1';
get_template_part( 'inc/post-detail-styles/'.$format.'-'.$post_style );
} else {
$post_style = get_post_meta($id, 'standard-post-detail-style', true) ? get_post_meta($id, 'standard-post-detail-style', true) : 'style1';
get_template_part( 'inc/post-detail-styles/'.$post_style );
}
?>
<?php endwhile; else :
endif;
//$next_post = get_next_post();
//if (!empty( $next_post )){
?>
<!--
<div class="infinite-navigation">
<div class="infinite-previous"><a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo $next_post->post_title; ?></a></div>
</div>
-->
<?php// } ?>
</div>
<?php get_footer(); ?>
这里我的代码用于无限滚动,但是当新帖子加载网址时没有改变任何最佳建议来实现这种情况。
控制台日志:
jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'click' of null TypeError: Cannot read property 'click' of null
at HTMLDocument.eval (eval at globalEval (https://code.jquery.com/jquery-2.1.4.min.js:2:2538), <anonymous>:2:52)
at j (https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29568)
at k (https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29882) undefined
r.Deferred.exceptionHook @ jquery.min.js:2
k @ jquery.min.js:2
jquery.min.js:2 Uncaught TypeError: Cannot read property 'click' of null
at HTMLDocument.eval (eval at globalEval (jquery-2.1.4.min.js:2), <anonymous>:2:52)
at j (jquery.min.js:2)
at k (jquery.min.js:2)