function true_load_posts(){
$args = unserialize(stripslashes($_POST['query']));
$args['paged'] = $_POST['page'] + 1; // следующая страница
$args['post_status'] = 'publish';
$first_page_post_count = 9;
$empty_pages_post_count = 8;
if ($args['paged'] > 1) {
$posts_per_page = $empty_pages_post_count;
if ($args['paged'] == 2) {
$offset = $first_page_post_count;
} else {
$offset = $first_page_post_count + ( $empty_pages_post_count * ($args['paged'] - 2));
}
} else {
$offset = 0;
$posts_per_page = $first_page_post_count;
}
$args['posts_per_page'] =>$posts_per_page;
$args['offset'] => $offset;
$q = new WP_Query($args);
if( $q->have_posts() ):
while($q->have_posts()): $q->the_post();
?>
<article class="col-md-3 col-sm-6 main-news text-left">
<time>
<?php the_time( 'j F, Y'); ?></time>
<div class="image-news">
<a href="<?php the_permalink(); ?>
">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'other-thumb' ); } ?></a>
</div>
<a href="<?php the_permalink(); ?>
" class="teaser-news">
<?php the_title(); ?></a>
</article>
<?php
endwhile;
endif;
wp_reset_postdata();
die();
}
add_action('wp_ajax_loadmore', 'true_load_posts');
add_action('wp_ajax_nopriv_loadmore', 'true_load_posts');