Files
agroexpert/partials/pinned-post.php
2024-04-03 22:24:30 +03:00

33 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// Получаем объект закрепленного поста из ACF поля 'pinned_post'
//$pinned_post = get_field('pinned_post', 'options');
$sticky_posts = get_option('sticky_posts');
// Получаем последний идентификатор прилепленного поста
$last_sticky_post_id = end($sticky_posts);
// Получаем объект поста по его идентификатору
$pinned_post = get_post($last_sticky_post_id);
if ($pinned_post) :
?>
<a href="<?php echo get_permalink($pinned_post->ID); ?>" class="hero-banner">
<div class="hero-banner__bg">
<?= show_post_image($pinned_post->ID); ?>
</div>
<p class="hero-banner__main">Главное</p>
<div class="hero-banner__content">
<p class="hero-banner__title subtitle-16">
<?php echo get_the_title($pinned_post->ID); ?>
</p>
<p class="hero-banner__text text-13">
<?php echo get_the_excerpt($pinned_post->ID); ?>
</p>
</div>
<div class="tag hero-banner__tag"><?php echo esc_html(get_category_name($pinned_post)); ?></div>
</a>
<?php endif; ?>