<?php

// Taxonomy Grid Component
global $mtm_grid_row_class;
$grid_query = mtm_taxonomy_query('grid');
$taxonomy = mtm_acf_taxonomy_property('grid', 'taxonomy');
$terms = mtm_acf_taxonomy_property('grid', 'slug');
$view = _get_field('mtm_show_view_all_link');
$mtm_grid_row_class = mtm_output_row_number();
$mtm_grid_module_class = 1;
?>

<h2 class="h1"><?php 
the_title();
edit_post_link('(Edit)', ' • ');
?>
</h2>
<div <?php 
post_class('mtm-component--main');
?>
>
	<?php 
mtm_get_template_part('mtm-content', 'component-page');
?>
</div>

<?php 
if (_get_field('mtm_show_taxonomy_links')) {
    mtm_terms_from_taxonomy_links($taxonomy);
    // output taxonomy links
}
<?php

// Topic Sections (ACF Repeater Field)
$display = get_field('mtm_home_stories_per_topic');
$mtm_news_feature_count = mtm_output_row_number();
if (have_rows('mtm_home_topic_sections')) {
    ?>

	<div class="mtm-component mtm-home-topics">
		<section class="content--page content--home-topics">

			<?php 
    while (have_rows('mtm_home_topic_sections')) {
        the_row();
        // Loop through each item
        ?>

				<?php 
        $topic_tax_query = mtm_taxonomy_query_sub('home_topic', $display, 'DESC');
        $i = 1;
        ?>

				<?php 
        if ($topic_tax_query->have_posts()) {
            ?>

					<div class="mtm-home-topic--single <?php 
            echo $mtm_news_feature_count;
            ?>
">
						<div class="mtm-home-topic--single-content">