<?php } ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<script>
var ajaxurl = '<?php echo site_url() ?>/wp-admin/admin-ajax.php';
var true_posts = '<?php echo serialize($wp_query->query_vars); ?>';
var current_page = <?php echo (get_query_var('paged')) ? get_query_var('paged') : 1; ?>;
var max_pages = '<?php echo $wp_query->max_num_pages; ?>';
</script>
<div id="load_more_gs">
</div>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/postload.js"></script>
jQuery(function(a){a(window).scroll(function(){var c={action:"loadmore",query:true_posts,page:current_page};a(document).scrollTop()>a(document).height()-2E3&&!a("body").hasClass("loading")&&a.ajax({url:ajaxurl,data:c,type:"POST",beforeSend:function(b){a("body").addClass("loading")},success:function(b){b?(a("#load_more_gs").before(b),a("body").removeClass("loading"),current_page++):a("#load_more_gs").remove()}})})});
function true_load_posts(){
$args = unserialize(stripslashes($_POST['query']));
$args['paged'] = $_POST['page'] + 1; // следующая страница
$args['post_status'] = 'publish';
$q = new WP_Query($args);
if( $q->have_posts() ):
while($q->have_posts()): $q->the_post();
<?php
endwhile; endif;
wp_reset_postdata();
die();
}
add_action('wp_ajax_loadmore', 'true_load_posts');
add_action('wp_ajax_nopriv_loadmore', 'true_load_posts');