Files
wordpress-theme-aksrt/templates/parts/special/special-grid.php
T

47 lines
1.9 KiB
PHP

<?php
/**
* Special Page Grid
*
* Renders the content grid for a special/topic page.
* Supports grid, list, and masonry layouts.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$posts = isset($posts) ? $posts : [];
$layout = isset($layout) ? $layout : 'grid';
$columns = isset($columns) ? (int) $columns : 2;
$show_dates = isset($show_dates) ? $show_dates : true;
if (empty($posts)) return;
?>
<div class="aksrt-special-grid aksrt-special-grid--<?php echo esc_attr($layout); ?>" style="--aksrt-cols:<?php echo esc_attr((string) $columns); ?>">
<?php foreach ($posts as $post) :
setup_postdata($post);
$img = get_the_post_thumbnail_url($post->ID, 'medium');
?>
<article class="aksrt-special-grid__item">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="aksrt-special-grid__link">
<?php if ($img) : ?>
<div class="aksrt-special-grid__thumb">
<img src="<?php echo esc_url($img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
</div>
<?php endif; ?>
<div class="aksrt-special-grid__body">
<h3 class="aksrt-special-grid__title"><?php echo esc_html($post->post_title); ?></h3>
<?php if ($post->post_excerpt) : ?>
<p class="aksrt-special-grid__desc"><?php echo esc_html(wp_trim_words($post->post_excerpt, 20)); ?></p>
<?php endif; ?>
<?php if ($show_dates) : ?>
<time class="aksrt-special-grid__date" datetime="<?php echo esc_attr(get_the_date('c', $post->ID)); ?>">
<?php echo esc_html(get_the_date('', $post->ID)); ?>
</time>
<?php endif; ?>
</div>
</a>
</article>
<?php endforeach; wp_reset_postdata(); ?>
</div>