Files
vij/blocks/moread.php

49 lines
1.4 KiB
PHP
Raw Normal View History

2021-09-18 01:30:09 +03:00
<?php
$posts = get_posts( array(
2022-08-17 00:29:25 +03:00
'numberposts' => 6,
2021-10-11 22:29:11 +03:00
'category' => 2, // пока тольео события
2021-09-18 01:30:09 +03:00
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'post_type' => 'post',
2021-11-11 23:15:08 +03:00
'post__not_in' => array($post_id),
2021-09-24 23:18:38 +03:00
'meta_query' => array(
array(
2023-03-27 23:26:09 +03:00
'key' => 'startevent',
'orderby' => 'meta_value',
'order' => 'DESC'
2021-09-24 23:18:38 +03:00
)
2021-11-11 23:15:08 +03:00
),
2021-09-18 01:30:09 +03:00
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );
# вывод поста
2022-08-17 00:29:25 +03:00
if( $posts ):
$nr = 0;?>
2021-09-18 01:30:09 +03:00
2021-09-20 01:07:53 +03:00
<div class="moread_rubric">Читайте также:</div>
2021-09-18 01:30:09 +03:00
<div class="moread">
2021-09-20 01:07:53 +03:00
2021-09-18 01:30:09 +03:00
<?php foreach($posts as $post):
2022-08-17 00:29:25 +03:00
$nr++;
2021-09-20 01:07:53 +03:00
setup_postdata( $post );?>
2021-09-18 01:30:09 +03:00
2022-08-17 00:29:25 +03:00
<div class="moread_card" id="moread_<?=$nr?>">
2022-10-30 01:46:41 +03:00
<?$imgurl = IMGSERVER.'news/512x340/'.str_replace('https://vetandlife.ru/wp-content/uploads/', '', get_the_post_thumbnail_url($post, 'full'))?>
<img src="<?php echo $imgurl;?>" alt="<?the_title();?>">
2021-09-20 01:07:53 +03:00
<div class="moread_title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></div>
<div class="moread_date"><?the_time('j F Y, G:i');?></div>
2021-09-18 01:30:09 +03:00
</div>
<?php endforeach;?>
</div>
<?php wp_reset_postdata();
endif?>