<?php
/**
 * The template to display related posts.
 *
 * This template can be overridden by copying it to
 * your-child-theme/views/post/single/related-posts.php.
 *
 * @param array $args
 *
 * @package MadeByAura\Prime
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime;

use MadeByAura\Prime\Helpers\EntryLoop;

defined( 'ABSPATH' ) || die();

// Entry loop.
$loop = new EntryLoop(
	[
		'layout'        => 'post-grid-small',
		'query_args'    => [
			'post_type'      => 'post',
			'posts_per_page' => 4,
			'post__not_in'   => [
				get_the_ID(),
			],
			'orderby'        => 'rand',
		],
		'pagination'    => false,
		'nothing_found' => false,
	],
);

// Don't proceed if there are no entires.
if ( ! $loop->have_entries() ) {
	return;
}
?>

<section class="aura-related-posts">
	<h1 class="aura-related-posts__title aura-h2">
		<?php echo esc_html__( 'You May Also Like', 'aura-prime' ); ?>
	</h1>

	<div class="aura-related-posts__body">
		<?php $loop->render_entries(); ?>
	</div>
</section>
