?> <div class="section-content section-news-content"> <div class="row"> <div class="content-grid" id="section-news-posts" data-layout="<?php echo esc_attr($layout); ?> "> <?php if ($latest_posts->have_posts()) { ?> <?php while ($latest_posts->have_posts()) { $latest_posts->the_post(); ?> <?php screenr_loop_post_item($post_class); ?> <?php } ?> <?php } else { ?> <?php get_template_part('template-parts/content', 'none'); ?> <?php } ?> </div> <div class="clear"></div>
function screenr_ajax_load_more_posts() { $paged = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; $latest_posts = new WP_Query(array('posts_per_page' => absint(get_theme_mod('news_num_post', 3)), 'ignore_sticky_posts' => true, 'paged' => $paged)); $layout = absint(get_theme_mod('news_layout', 3)); if (!$layout) { $layout = 3; } $post_class = ''; switch ($layout) { case 1: $post_class = 'col-md-12'; break; case 2: $post_class = 'col-md-6'; break; case 4: $post_class = 'col-md-6 col-lg-3'; break; default: $post_class = 'col-md-6 col-lg-4'; break; } if ($latest_posts->have_posts()) { while ($latest_posts->have_posts()) { $latest_posts->the_post(); screenr_loop_post_item($post_class); } } wp_reset_postdata(); wp_die(); }