max_num_pages > 1) { ?>

have_posts()): ob_start(); $archive_style = $_POST['template']; set_query_var('archive_style', $archive_style); // Load a different template for search page else load archive template $template_part = (isset($query_vars['s']) && !empty($query_vars['s'])) ? 'search' : 'archive'; while ($posts->have_posts()):$posts->the_post(); get_template_part('template-parts/content', $template_part); endwhile; wp_reset_postdata(); $output['content'][] = ob_get_clean(); wp_send_json_success($output); else: $error = new WP_Error('500', __('No More Posts', 'avenews')); wp_send_json_error($error); endif; wp_die(); } endif; add_action('wp_ajax_avenews_load_posts', 'avenews_load_posts'); add_action('wp_ajax_nopriv_avenews_load_posts', 'avenews_load_posts');