<?php get_header();?>

    
    <div id="content"> 
        
        <?//while(have_posts()):?>
            <?the_post();?>

        
        <?php $category = get_the_category();
        $category_id = $category[0]->term_id;
        $category_link = get_category_link($category_id);
        ?>

        <ul id="nav_content">
         <li><a href="https://vetandlife.ru">Главная</li>
         <li>-<li> 
        <li><a href="<?=$category_link?>"><?=$category['0']->name;?></a></li>
        <li>-<li>
        <li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
        </ul>   

        <div class="post_info">
            <div class="post_info_sub">
                <span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>
            </div> 
            <div class="post_info_sub  post_info_social">
                <?php include get_template_directory().'/blocks/social-share.php';?>
            </div>
        </div>

        <div id="fulltext">

        <?// Получаем значение метаполя "completed" для текущей записи
        $post_id = get_the_ID();

        if ( metadata_exists( 'post', $post_id, 'completed' ) ) {
            $completed = get_post_meta($post_id, 'completed', true);
        } else {
            $completed = false; 
        }

        
        // Проверяем, установлена ли галочка "Завершено"
        if ($completed === 'yes') {
            echo '<h1 class="post-h1">'.get_the_title().'</h1>
            <p>Мероприятие завершено. Посмотрите <span class="post_link_category"><a href="/category/vystavki-i-konferenitsii">актуальные мероприятия</a></span> или воспользуйтесь нашим поиском.</p>';
        } else { ?> 
            
        <h1 class="post-h1"><?php wp_title('');?></h1>
 
        <?$author = get_the_author();
        
        if ( ! empty ( $author ) AND $author !== 'vetandlife.ru' AND $author !== 'Анна Купровская'):?>
            <div class="post_author">
                Автор: <?php the_author(); ?>
            </div>  
        <?endif?>  

        <?if ( has_post_thumbnail() ) :?> 
            <div id="event-img">
                <img class="img-fluid rounded" width="198" src="<?php echo get_the_post_thumbnail_url(null, 'full');?>" alt="<?the_title();?>">
            </div>
        <?endif?>    
        <div class="fulltext"><?the_content();?></div>
        <!--<p><small class="text-muted"><?php the_tags('');?></small></p> -->
        <?//endwhile;?> 

        <?}?>


        </div>

        <?php include get_template_directory().'/blocks/moread_events.php';?>

        <?php // include get_template_directory().'/blocks/yets.php';?>

        <div id="tags">
            <?php the_tags();?>
        </div>        
        
        <div class="post_panel_info">
            <div class="post_panel_info_sub">
                <span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <?php the_time('j F Y, G:i');?>
            </div>
            <div class="post_panel_info_sub">
                <!--Поделиться <i class="fas fa-share-square btn_soc_post"></i>-->  <?php include get_template_directory().'/blocks/social-share.php';?>
            </div>
        </div> 

        <div class="publ-to-main"><a href="https://vetandlife.ru"> <span class="arrow-go-main"><</span>&nbsp;&nbsp;&nbsp;<span class="go-to-main">На главную</span></a></div>

     
    </div>

    



<?php get_footer();?>
