Php AJAX加载更多插件加载已经显示的帖子
我在一个有多个部分的网页上工作,每个部分都有多个循环,具有多个类别。我使用Ajax加载更多插件为每个部分加载新帖子。问题是,当我单击LoadMore时,它会同时加载已经显示的帖子和尚未显示的帖子。我希望它只加载尚未显示的新帖子 以下是我使用的快捷码:Php AJAX加载更多插件加载已经显示的帖子,php,ajax,wordpress,Php,Ajax,Wordpress,我在一个有多个部分的网页上工作,每个部分都有多个循环,具有多个类别。我使用Ajax加载更多插件为每个部分加载新帖子。问题是,当我单击LoadMore时,它会同时加载已经显示的帖子和尚未显示的帖子。我希望它只加载尚未显示的新帖子 以下是我使用的快捷码: echo do_shortcode('[ajax_load_more container_type="div" post_type="post" posts_per_page="3" preloaded="true" preloaded_amoun
echo do_shortcode('[ajax_load_more container_type="div" post_type="post" posts_per_page="3" preloaded="true" preloaded_amount="4" pause="true" scroll="false" button_loading_label="Loading..." seo="true" category="church-music-news"]');
这是部分的循环
<div class="row">
<div class="col-lg-12 col-sm-12">
<div class="music_box bg-color1">
<div class="music_box_top">
<?php
$sticky = get_option( 'sticky_posts' );
rsort( $sticky );
$args = array(
'post__in' => $sticky,
'posts_per_page' => 1,
'cat' => 34
);
$sticky_query = new WP_Query( $args );
while ( $sticky_query->have_posts() ) : $sticky_query->the_post();
?>
<a href="<?php the_permalink(); ?>">
<div class="fashion_box_thumb">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array() );
}
?>
</div>
</a>
<div class="fashion_box_text">
<a href="<?php the_permalink(); ?>">
<h3><?php the_title(); ?></h3>
</a>
<p><?php the_excerpt(); ?></p>
<div class="post_cont_icons">
<span class="fa fa-comments cmnt"> <?php comments_number('0','1','%'); ?></span>
<?php echo getPostLikeLink(get_the_ID());?>
<span class="matchtime2"><i class="fa fa-clock-o"></i> <?php the_time();?><br></span>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<div class="clear"></div>
</div><!--music_box_top-->
<div class="fashion_box_bottom">
<?php
$args = array(
'post__not_in' => get_option( 'sticky_posts' ),
'posts_per_page' => 4,
'cat' => 34
);
$sticky_query = new WP_Query( $args );
$count = 0;
while ( $sticky_query->have_posts() ) : $sticky_query->the_post(); ?>
<?php $count++; ?>
<?php if ($count == 1) :
?>
<div class="fashion_box_bottom_item">
<a href="<?php the_permalink(); ?>">
<h4><?php the_title(); ?></h4>
</a>
</div>
<?php elseif ($count == 2) : ?>
<div class="fashion_box_bottom_item">
<a href="<?php the_permalink(); ?>">
<h4><?php the_title(); ?></h4>
</a>
</div>
<?php elseif ($count == 3) : ?>
<div class="fashion_box_bottom_item">
<a href="<?php the_permalink(); ?>">
<h4><?php the_title(); ?></h4>
</a>
</div>
<?php elseif ($count == 4) : ?>
<div class="fashion_box_bottom_item">
<a href="<?php the_permalink(); ?>">
<h4><?php the_title(); ?></h4>
</a>
</div>
<div class="clear"></div>
</div><!--music_box_bottom-->
</div><!--music_box-->
</div><!--col-lg-12-->
<?php else :
get_template_part( 'woodclefpro/pro_template3' );
endif;
endwhile;
wp_reset_postdata(); ?>
</div><!--row-->
<div class="row">
<?php
echo do_shortcode('[ajax_load_more container_type="div" post_type="post" posts_per_page="3" preloaded="true" preloaded_amount="4" pause="true" scroll="false" button_loading_label="Loading..." seo="true" category="church-music-news"]');
?>
</div>
这是为那些可能遇到上述问题并面临与我相同问题的人准备的。下面是我如何解决它的
在endwhile
$do_not_duplicate[] = $post->ID;
将此添加到您的快捷码中:post\u not\u in=“”.$post\u not\u in.”“
最后一个短代码如下所示:
echo do_shortcode('[ajax_load_more ajax_load_more post__not_in="'.$post__not_in.'" container_type="div" post_type="post" posts_per_page="3" preloaded="true" preloaded_amount="4" pause="true" scroll="false" button_loading_label="Loading..." seo="true" category="church-music-news"]');
不完全正确。事实上,在这个插件的一个插件的页面上,模板输出的单个条目,例如“single.php”应该只是一个短代码。所有content single.php都应该放在插件使用的模板中。对不起,我的英语不好。
注意:Ajax Load More将负责加载所有帖子,包括
用户登录页面时的初始帖子。所有这些都应该保留下来
在single.php循环中是ajax\u load\u more短代码(如图所示)
上文)