shkola/wp-content/themes/dekart/page-news.php

59 lines
1.5 KiB
PHP

<?php
/*
Template Name: Шаблон страницы Новости
*/
?>
<?php
get_header();
$post_id = get_the_ID();
?>
<main class="page contacts">
<section class="contetn-main_block">
<div class="container">
<h1 class="page_h2"><?php the_title()?></h1>
<?php
$args = array(
'posts_per_page' => -1,
'offset' => 0,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
);
$query = new WP_Query($args); ?>
<div class="news-wrapper">
<?php
while ($query->have_posts()) {
$query->the_post();
$post_id = get_the_ID();
$cat = get_the_category($post_id);
?>
<article class="news__item show" data-item-cat="<?php echo $cat[0]->cat_ID; ?>">
<a href="<?php the_permalink(); ?>">
<span class="news_label_cat">Новости</span>
<div class="popular__subject_img">
<?php if ( has_post_thumbnail()) { ?>
<?php the_post_thumbnail(); ?>
<?php } ?>
</div>
<div class="product-info">
<span class="news_label"><?php echo get_the_date( 'd.m.Y' ); ?></span>
<h3 class="popular__subject_title"><?php the_title(); ?></h3>
<p class="popular__subject_text"><?php echo wp_trim_words( get_the_excerpt(), 25 ); // post excerpt; ?></p>
</div>
</a>
</article>
<?php } wp_reset_postdata(); ?>
</div>
</div>
</section>
<?php get_template_part( 'template-parts/map' ); ?>
</main>
<?php
get_footer();