아래의 루프를 사용하여 다음 페이지 세트를로드하고 첫 번째 클릭에서 작동하지만 다음 페이지가로드되고 "새로운 게시물"을 클릭하면 작동합니다 전체 페이지를 다시로드합니다. 어떤 아이디어? 당신은 물론 동적으로 컨텐츠를 삽입 $.ajax
에 대한 바로 가기가 인 내용을 삽입하는 jQuery의 load()
방법을 사용하고간단한 Wordpress AJAX 페이지 매김
<div id="content">
<?php
$new_query = new WP_Query();
$new_query->query('post_type=post&showposts=1'.'&paged='.$paged);
?>
<?php while ($new_query->have_posts()) : $new_query->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<div id="pagination">
<?php next_posts_link('« Older Entries', $new_query->max_num_pages) ?>
<?php previous_posts_link('Newer Entries »') ?>
</div>
</div><!-- #content -->
<script>
$('#pagination a').on('click', function(event){
event.preventDefault();
var link = $(this).attr('href'); //Get the href attribute
$('#content').fadeOut(500, function(){ });//fade out the content area
$('#content').load(link + ' #content', function() { });
$('#content').fadeIn(500, function(){ });//fade in the content area
});
</script>
이 나를 위해 매김 링크, 어떤 아이디어를 생성하지 않습니다? 또한 $ page의 가치는 무엇입니까? 코드에서 볼 수없는 부분은 – trainoasis