add mored evevnts

This commit is contained in:
arlemp@selectel.ru
2023-03-27 23:26:09 +03:00
parent 5f000ece92
commit 2221530741
3 changed files with 51 additions and 7 deletions

View File

@@ -7,14 +7,14 @@ $posts = get_posts( array(
'order' => 'DESC', 'order' => 'DESC',
'include' => array(), 'include' => array(),
'exclude' => array(), 'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'post', 'post_type' => 'post',
'post__not_in' => array($post_id), 'post__not_in' => array($post_id),
'meta_query' => array( 'meta_query' => array(
array( array(
'key' => '_thumbnail_id', 'key' => 'startevent',
//'compare' => 'EXISTS' 'orderby' => 'meta_value',
'order' => 'DESC'
) )
), ),
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса

44
blocks/moread_events.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
$more_posts = get_posts( array(
'numberposts' => 6,
'category' => 61, // пока тольео события
'meta_key' => 'startevent',
'meta_value' =>'',
'post_type' => 'post',
'post__not_in' => array($post_id),
'meta_query' => array(
array(
'key' => '_thumbnail_id',
//'compare' => 'EXISTS'
)
),
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );
# вывод поста
if( $more_posts ):
$nr = 0;?>
<div class="moread_rubric">Другие мероприятия:</div>
<div class="moread">
<?php foreach($more_posts as $post):
$nr++;
setup_postdata( $post );?>
<div class="moread_card" id="moread_<?=$nr?>">
<?$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();?>">
<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>
</div>
<?php endforeach;?>
</div>
<?php wp_reset_postdata();
endif?>

View File

@@ -50,7 +50,9 @@
</div> </div>
<?php include get_template_directory().'/blocks/yets.php';?> <?php include get_template_directory().'/blocks/moread_events.php';?>
<?php // include get_template_directory().'/blocks/yets.php';?>
<div id="tags"> <div id="tags">
<?php the_tags();?> <?php the_tags();?>
@@ -65,8 +67,6 @@
</div> </div>
</div> </div>
<?php include get_template_directory().'/blocks/moread.php';?>
<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 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>