<?php get_header(); ?>
<?php

$post = get_queried_object_id();
$email = str_replace("-", ".", get_post_meta($post, 'cap-user_login', true))."@news-profile.ru";

?>
    <div class="row clearfix">
        <div class="col-12 col-md-8 col-xl-9">
            <?php if(get_post_meta($post, 'show_data', true) == 1): ?>
                <div class="author" itemscope itemtype="https://schema.org/Person">
                    <div class="position-relative d-flex flex-column flex-md-row">
                        <div class="text-center text-md-left">
                            <img itemprop="image" loading="lazy" class="author__img" src="<?php echo wp_get_attachment_image_src( get_post_thumbnail_id($post), 'thumbnail' )[0]; ?>" width="166" height="166" alt="<?php echo the_title(); ?>" />
                        </div>
                        <div class="d-flex flex flex-column align-items-center align-items-md-start justify-content-between">
                            <div class="author__body d-flex flex flex-column align-items-center align-items-md-start justify-content-center">
                                <h3 class="author__title mt-3 mt-md-0 mb-2 mb-md-2" itemprop="name">
                                    <?php echo the_title(); ?>
                                </h3>
                                <div class="author__post text-center text-md-left py-1 py-md-0 mb-4 mb-md-0">
                                    <a href="mailto:<?=$email?>" itemprop="email"><?=$email?></a>
                                </div>
                                <div class="author__post text-center text-md-left py-1 py-md-0 mb-4 mb-md-0">
                                    <?= get_post_meta($post, 'cap-description', true); ?>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            <?php endif; ?>
            <div class="row clearfix d-block">
                <?php if ( have_posts() ) : ?>
                        <?php
                                $rand = rand(4,5);
                                $postNum = 0;
                                while ( have_posts() ) : $postNum++;
                                    ad_inlist_mobile($postNum);
                                    the_post();
                                    if ($postNum == $rand && $already == false ):
                                        $already = true;
                                        get_template_part( 'content', 'preview-long-rubrick' );
                                    else:
                                        get_template_part( 'content', 'preview-short-rubrick' );
                                    endif;
                                endwhile;
                                if (is_tag()):
                                    echo do_shortcode('[ajax_load_more cache="true" cache_id="'.wp_is_mobile().crc32('archive-author-tag').get_queried_object_id().get_last_id().'" id="category_request" scroll_distance="50" button_label="Загрузить еще" container_type="div" post_type="profile_article,anew" offset="'.(get_option('posts_per_page')).'" posts_per_page="10" tag__and="'.get_queried_object()->term_id.'"]');
                                endif;
                                if(is_category()):
                                        $cat = get_queried_object()->term_id;
                                        $category = get_category ($cat);
                                        echo do_shortcode('[ajax_load_more cache="true" cache_id="'.wp_is_mobile().crc32('archive-author-category').get_queried_object_id().get_last_id().'" id="category_request" scroll_distance="50" button_label="Загрузить еще" container_type="div" post_type="profile_article,anew" offset="'.(get_option('posts_per_page')).'" posts_per_page="10" category="'.$category->slug.'"]');
                                endif;
                                if(is_author()):
                                    echo do_shortcode('[ajax_load_more cache="true" cache_id="'.wp_is_mobile().crc32('archive-author-author').get_queried_object_id().get_last_id().'" id="author_request" scroll_distance="50" button_label="Загрузить еще" container_type="div" post_type="profile_article" offset="'.(get_option('posts_per_page')).'" posts_per_page="10" author="'.get_the_author_meta('ID').'" ]');
                                endif;
                        ?>
                    <div class="hide-if-js">
                        <?php
                        the_posts_pagination(
                            [
                                'end_size'     => 3,
                                'mid_size'     => 3,
                                'prev_next'    => 0,
                            ]
                        );
                        ?>
                    </div>
                <?php
                        else :
                                get_template_part( 'content', 'none' );
                        endif;
                ?>

            </div>
        </div>
        <div class="col-12 col-md-4 col-xl-3">
            <div class="right-side">
                    <?php dynamic_sidebar('right_sidebar'); ?></div>
                    <div class="js-stickybit">
                        <?php get_template_part( 'content', 'ad' ); ?>
                    </div>
            </div>
        </div>
    </div>
<?php get_footer(); ?>