我的ajax完美运行,现在我需要我的页面才能在页面上运行。我不知道如何开始..另一个问题是我需要一次引入16个帖子。请帮助
如何将其更改为下一个和之前的分页 下面的HTML
<ul id="sermonserie1">
while ( $query->have_posts() ) : $query->the_post();
<a href="javascript:void(0)" class="button load-more" page="1">Next page</a>
<?php endwhile;?>
</ul>
ajax page
global $post, $wpdb;
if(isset($_POST['pagi'])) {
if( isset($_REQUEST["locations"]) || isset($_REQUEST["speaker"]) || isset($_REQUEST["topic"])) {
if ($_REQUEST["locations"]!='#' ) {
$locat_termy = array('sermons', $_REQUEST['locations']);
} else {
$locat_termy = array('sermons');
$locations_resource = get_term_children( 16, 'category' );
foreach ( $locations_resource as $child_location ) {
$location_term = get_term_by( 'id', $child_location, 'category' );
$locat_termy[] .= $location_term->slug;
}
//print_r($locations_resource);
//print_r($locat_termy);
}
$all_args = array(
'post_type' => 'resources',
'author' => $speak,
'posts_per_page' => -1,
'tax_query' => array (
'relation' => 'OR',
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $topicids,
),
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $locat_termy,
),
) ,'date_query' => $thedate
);
$query = new WP_Query( $all_args );
//print_r($query);
//$eevents = array();
//print_r($query);
while ( $query->have_posts() ) : $query->the_post();?>
<?php endwhile; ?>
<?php }
} ?>
这是我的js
jQuery('.button.load-more').live('click', function() {
var pagenum = parseInt(jQuery(this).attr('page'))+ 1;
jQuery.ajax({
type: 'post',
url: 'http://cj.co.za/back/page/'+pagenum+'',
data: {
pagi:1,
},
success: function(data) {
jQuery('#sermonserie1').append(data);
jQuery('.button.load-more').attr('page', pagenum)
},
error: function() {
jQuery('.button.load-more').text('No page');
}
});
});