代码拉取完成,页面将自动刷新
<?php
/*
* Template Name: pro_list
*/
?>
<?php
get_header();
?>
<div class="page2 pro-list">
<div class="wrap clearfix">
<div class='pro-list-wrap clearfix' id="article-list">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$posts_per_page = get_category(get_query_var('cat'))->category_parent == 0 ? 999 : 999;
// exit;
$args = array(
'caller_get_posts' => 1,
'cat' => get_query_var('cat'),
'paged' => $paged,
'posts_per_page' => $posts_per_page,
);
query_posts($args);
while (have_posts()) {
the_post();
?>
<div class="pro-item article-item">
<a href="<?php echo home_url('index.php/detail/?post_id=' . $post->ID); ?>" class='link-wrap'>
<div class="pic-wrap">
<?php if (has_post_thumbnail()) {
the_post_thumbnail('pro');
} else {?>
<img src="<?php bloginfo('template_url');?>/images/dot.jpg" alt="..." />
<?php }?>
</div>
<div class="title"><?php the_title();?></div>
<div class='desc'>
<?php echo get_post_meta($post->ID, 'desc', true); ?>
</div>
</a>
</div>
<?php
}
?>
</div>
<?php
wp_reset_query();
?>
</div>
</div>
<script>
$('loading')
$('.article-paging > a').on('click',function(){ //点击实现加载更多,你可以根据自己需要改成下拉自动加载
var next_url = $(this).attr("href");
var next_text = $(this).text();
$.ajax({
type: 'get',
url: next_url + '#article-list',
success: function(data){
result = $(data).find("#article-list .article-item");
next_link = $(data).find(".article-paging > a").attr("href");
//$(this).attr("href", next_url);
if (next_link != undefined){
$('.article-paging > a').attr("href", next_link);
}else{
$(".loading-more").remove();
}
console.log(result);
$(function(){
$("#article-list").append(result.css({display: 'inline-block'}).fadeIn(300));
$('.thumb').lazyload({
data_attribute: 'src',
placeholder: _BGJ.uri + '/static/img/thumbnail.png',
threshold: 400
});
});
$(function() {
if (next_url.indexOf("page") < 1) {
$("#article-list").html('');
}
$("#article-list").append(result.fadeIn(200));
});
}
});
return false;
});
</script>
<?php
get_footer();
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。