<?php
/**
 * Template name: Directory - 2 columns
 *
 * @package Multi
 */

?>

<?php

get_header();

if ( have_posts() ) :
	while ( have_posts() ) :
		the_post();
		get_template_part( 'template-parts/top-slider' );
		get_template_part( 'template-parts/content-start' );

		$multimagazine_show_title = multimagazine_title_pos_default();
		?>
		<div class="main directory">
			<div class="page single">
				<?php if ( 'off' !== $multimagazine_show_title ) : ?>
				<h1 class="page-title"><?php the_title(); ?></h1>
				<?php endif; ?>
				<?php if ( ! empty( $post->post_content ) ) : ?>
					<div class="post-content"><?php the_content(); ?></div>
				<?php endif; ?>
			</div>

	<div class="in-page-search"><?php get_search_form(); ?></div>
			<?php
			$multimagazine_options         = array(
				'orderby' => 'name',
				'parent'  => 0,
			);
			$multimagazine_main_categories = get_categories( $multimagazine_options );
			if ( count( $multimagazine_main_categories ) ) :
				?>
				<div class="columns">
				<?php foreach ( $multimagazine_main_categories as $multimagazine_cat ) : ?>
					<div class="col col2">
						<h2 class="main-cat"><a href="<?php echo esc_url( get_category_link( $multimagazine_cat->term_id ) ); ?>"><?php echo esc_html( $multimagazine_cat->name ); ?></a> (<?php echo esc_html( $multimagazine_cat->count ); ?>)</h2>
						<p class="subcats"><?php wp_kses_post( multimagazine_get_subcat_list( $multimagazine_cat->term_id ) ); ?></p>
					</div>
				<?php endforeach; ?>
				</div>
			<?php endif; ?>
</div>
		<?php
	endwhile;
endif;
?>
<?php
$multimagazine_sidebar_position = get_post_meta( $multimagazine_current_page_id, 'multi_sidebar_position', true );
if ( empty( $multimagazine_sidebar_position ) ) {
	$multimagazine_sidebar_position = $multimagazine_sidebar_pos_global;
}
if ( 'off' !== $multimagazine_sidebar_position ) {
	get_sidebar();
}
?>
<?php get_footer(); ?>
