<?php
/**
 * Post latest content
 *
 * @package wpstream-theme
 */

$use_transient = wpstream_theme_return_use_transient();

$transient_key = 'wpstream_theme_latest_blog_post';

$latest_post_query_args = array(
	'post_status'    => 'publish',
	'post_type'      => 'post',
	'posts_per_page' => 4,
	'orderby'        => 'date', // Order by post date.
	'order'          => 'DESC', // Sort in descending order (latest first).
);

$query = wpstream_theme_custom_query( $latest_post_query_args, $transient_key, $use_transient );

$archive_link = get_post_type_archive_link( $query->query_vars['post_type'] ?? '' ) | home_url();
$link_more    = add_query_arg( $query->query, $archive_link );

if ( $query->found_posts > 0 ) {
	?>

	<section class="wpstream_section wpstream_latest_post">
		<div class="<?php echo esc_attr( wpstream_theme_container_class() ); ?>">

			<div class="wpstream-grid-main">
				<h2 class="title-more">

					<?php
					// Section Title.
					echo esc_html( $wpstream_section_title ?? '' );
					?>
				</h2>
				<div class="row">

					<?php
					// The query to display results.
					include get_template_directory() . '/template-parts/single/post-loop-content.php';
					?>

				</div>
			</div>
		</div>
	</section>
<?php } ?>