<?php
/**
 * Search results list - "Masonry fullwidth" layout
 *
 * @package Multi
 */

?>
<main class="main">
<?php
get_template_part( 'template-parts/search-header' );

$current_category = get_query_var( 'cat' );
$multimagazine_options    = array(
	'hierarchical' => false,
	'parent'       => $current_category,
);
$categories       = get_terms( 'category', $multimagazine_options );
if ( count( $categories ) ) :
	?>
<div class="filters">
	<ul class="filter-list">
		<?php foreach ( $categories as $category ) : ?>
		<li><a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"><?php echo esc_html( $category->name ); ?></a></li>
		<?php endforeach; ?>
	</ul>
</div>
<?php endif; ?>
<div class="postlist postlist-masonry masonry m4 <?php echo esc_attr( multimagazine_get_post_loading_classes() ); ?>">

<?php
if ( have_posts() ) :
	$multimagazine_post_args = multimagazine_postlist_meta_flags();

	while ( have_posts() ) {
		the_post();
		get_template_part( 'post-list-parts/post-masonry', null, $multimagazine_post_args );
	}
	?>
	</div>
	<?php get_template_part( 'template-parts/pager' ); ?>
<?php else : ?>
	<?php get_template_part( 'search-no-results' ); ?></div>
<?php endif; ?>
</main>
