max_num_pages > 1 ) { ?>
have_posts() ) : ob_start(); $allowed_templates = array( 'archive_style_1', 'archive_style_2', 'archive_style_3', 'archive_style_4', 'archive_style_5', 'archive_style_6', 'archive_style_7', 'archive_style_8', 'archive_style_9', ); $archive_style = sanitize_file_name( $_POST['template'] ); set_query_var( 'archive_style', $archive_style ); // Set a query var for new query to work with the default query. set_query_var( 'archive_query', $posts ); // Load a different template for search page else load archive template. if ( $is_search ) { $template_part = 'template-parts/content/content-search'; } elseif ( in_array( $archive_style, $allowed_templates, true ) ) { $template_part = 'template-parts/archive/styles/' . $archive_style; } else { $template_part = ''; $error = new WP_Error( '500', __( 'Template Not Found', 'blogvy' ) ); wp_send_json_error( $error ); } if ( ! empty( $template_part ) ) { get_template_part( $template_part ); } $output['content'][] = ob_get_clean(); wp_send_json_success( $output ); else : $error = new WP_Error( '500', __( 'No More Posts', 'blogvy' ) ); wp_send_json_error( $error ); endif; wp_die(); } endif; add_action( 'wp_ajax_blogvy_load_posts', 'blogvy_load_posts' ); add_action( 'wp_ajax_nopriv_blogvy_load_posts', 'blogvy_load_posts' );