<?php namespace core_next;
global $core_next_set;
if ($core_next_set['open_related_articles']) {
    ?>
    <div class="related-articles">
        <div class="related-title">
            <?php echo $core_next_set['open_related_title']; ?>
        </div>
        <?php
        $cat_obj = get_the_category(get_the_ID());
        $cat_id = $cat_obj[0]->term_id;

        if ($core_next_set['related_articles_theme'] == 'list') {
            $list = WordPress::getPostListByCatID($cat_id, $core_next_set['related_articles_num'], ['a']);
            Template::echoListTemplateHtml('related-articles-list-item', $list, ['plane_name' => 'div', 'plane_class_name' => 'related-articles-list']);
        } else if ($core_next_set['related_articles_theme'] == 'card') {
            $list = WordPress::getPostListByCatID($cat_id, $core_next_set['related_articles_num'], ['thumbnail']);
            Template::echoListTemplateHtml('related-articles-list-card', $list, ['plane_name' => 'div', 'plane_class_name' => 'related-articles-card-list']);
        } else if ($core_next_set['related_articles_theme'] == 'post_list') {
            $list = WordPress::getPostListByCatID($cat_id, $core_next_set['related_articles_num']);
            $list = WordPress::handelPostList($list);
            Template::echoListTemplateHtml('related-articles-list-post-list', $list, ['plane_name' => 'div', 'plane_class_name' => 'related-articles-post-list']);
        }
        ?>
    </div>
    <?php
}
?>
