add card_post_id

This commit is contained in:
2022-01-18 22:15:28 +03:00
parent f62d46fcdf
commit 00c96d16eb
3 changed files with 33 additions and 13 deletions

31
blocks/card_post_id.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
function card_post_id( $id, $news_date = '') {
$curr_post = get_post( $id );?>
<div class="mini-card">
<?if ( has_post_thumbnail($curr_post->ID) ) :?>
<div class="mini-card-img">
<a href="<?the_permalink($curr_post->ID);?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url($curr_post->ID); ?>" alt="<?=$curr_post->post_title;?>">
<?if( has_tag( 'видео' ) ):?>
<span class="play-card"></span>
<?endif?>
</a>
</div>
<?endif?>
<h2 class="mini-card-title"><a href="<?the_permalink($curr_post->ID);?>"><?=$curr_post->post_title?></a></h2>
<div class="mini-card-body">
<div class="news_date">
<?if ($news_date == ''):?>
<?=get_the_time('j F Y, G:i', $curr_post->ID);?>
<?else:?>
<?=$news_date?>
<?endif?>
</div>
</div>
</div>
<?}?>

View File

@@ -17,6 +17,7 @@ require get_template_directory().'/src/calend-block.php';
require get_template_directory().'/src/calendar.php';
require get_template_directory().'/src/perevod.php';
require get_template_directory().'/lang.php';
require get_template_directory().'/blocks/card_post_id.php';
//require ABSPATH.'vendor/masterforweb/db_lite/db_lite.php';

View File

@@ -39,19 +39,7 @@ $nn = 0;?>
<?if ($nn == 10):?>
<div class="mini-card">
<?$block_href = "https://vetandlife.ru/sobytiya/veterinariya-i-zhizn-obyavlyaet-o-novom-fotokonkurse-sovremennoe-zhivotnovodstvo-i-veterinariya/";?>
<div class="mini-card-img">
<a href="<?=$block_href?>">
<img class="mini-card-img" src="https://vetandlife.ru/wp-content/uploads/2022/01/Nikola-Stojadinovic-iStock.jpg" alt="«Ветеринария и жизнь» объявляет о новом фотоконкурсе «Современное животноводство и ветеринария»">
</a>
</div>
<h2 class="mini-card-title"><a href="<?=$block_href?>">«Ветеринария и жизнь» проводит новый фотоконкурс «Современное животноводство и ветеринария»</a></h2>
<div class="mini-card-body">
<div class="news_date">до 31 марта 2022 года</div>
</div>
</div>
<?card_post_id(18170, 'до 31 марта 2022 года')?>
<?endif?>