wp-duckbehaviorjournal/archive-letter.php
Kumi 5adf97494d
feat: add Letters to the Editor post type
Introduced a new custom post type "Letters to the Editor" with corresponding archive and single templates. Enhanced post type functionality includes support for featured images, authors, excerpts, and comments. Added pagination and a meta box for article authors to improve user interaction and content management.
2024-06-20 20:53:04 +02:00

44 lines
No EOL
2 KiB
PHP

<?php get_header(); ?>
<!-- Archive Content -->
<section class="container my-5">
<h1 class="display-4 text-center">Letters to the Editor</h1>
<div class="row">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<?php if (has_post_thumbnail()) : ?>
<img src="<?php the_post_thumbnail_url(); ?>" class="card-img-top" alt="<?php the_title(); ?>">
<?php endif; ?>
<div class="card-body">
<h5 class="card-title"><?php the_title(); ?></h5>
<p class="card-text"> <?php
$authors = get_post_meta(get_the_ID(), 'article_authors', true);
if (!empty($authors)) {
echo implode(', ', array_map('esc_html', $authors));
} else {
the_author();
}
?> | <?php the_date(); ?></p>
<p class="card-text"><?php the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>" class="btn btn-outline-primary">Read More</a>
</div>
</div>
</div>
<?php endwhile;
else : ?>
<p><?php _e('Sorry, no letters found.', 'duck-behavior-journal'); ?></p>
<?php endif; ?>
</div>
<div class="row">
<div class="col-md-12">
<?php
echo paginate_links(array(
'total' => $wp_query->max_num_pages,
));
?>
</div>
</div>
</section>
<?php get_footer(); ?>