Files
wordpress-theme-aksrt/templates/parts/docs/doc-index-card.php
T

56 lines
1.9 KiB
PHP

<?php
/**
* Document Index Card
*
* Shows a card for a document page on the document navigation index.
* Used in the document navigation page to list available documents.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$page_id = get_the_ID();
$children = get_pages([
'parent' => $page_id,
'sort_column' => 'menu_order',
'sort_order' => 'ASC',
'post_status' => 'publish',
]);
$child_count = count($children);
$thumb = get_the_post_thumbnail_url($page_id, 'medium');
$excerpt = wp_trim_words(get_the_excerpt(), 30, '...');
?>
<a href="<?php the_permalink(); ?>" class="aksrt-doc-index-card">
<?php if ($thumb) : ?>
<div class="aksrt-doc-index-card__thumb">
<img<?php echo aksrt_get_lazy_attr('lazy_other', (string) $thumb); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="">
</div>
<?php else : ?>
<div class="aksrt-doc-index-card__icon">
<i class="fa fas fa-book"></i>
</div>
<?php endif; ?>
<div class="aksrt-doc-index-card__body">
<h3 class="aksrt-doc-index-card__title"><?php the_title(); ?></h3>
<?php if ($excerpt) : ?>
<p class="aksrt-doc-index-card__desc"><?php echo esc_html($excerpt); ?></p>
<?php endif; ?>
<div class="aksrt-doc-index-card__meta">
<?php if ($child_count > 0) : ?>
<span class="aksrt-doc-index-card__count">
<i class="fa fas fa-file-alt"></i>
<?php printf(esc_html__('%d 篇文章', 'aksrt'), $child_count); ?>
</span>
<?php endif; ?>
<span class="aksrt-doc-index-card__date">
<i class="fa fas fa-clock"></i>
<?php echo esc_html(get_the_date('', $page_id)); ?>
</span>
</div>
</div>
<i class="fa fas fa-chevron-right aksrt-doc-index-card__arrow"></i>
</a>