checkvorteil/single.php
2025-06-16 15:14:17 +02:00

79 lines
2.6 KiB
PHP

<?php
// filepath: /home/michi/landingpages/checkvorteil-wordpress/single.php
get_header(); ?>
<div class="container">
<?php while (have_posts()) : the_post(); ?>
<nav class="breadcrumbs">
<a href="<?php echo home_url(); ?>">Home</a> /
<a href="<?php echo get_permalink(get_option('page_for_posts')); ?>">Blog</a> /
<?php the_title(); ?>
</nav>
<a href="<?php echo get_permalink(get_option('page_for_posts')); ?>" class="back-btn">
← Zurück zum Blog
</a>
<article class="content">
<header>
<?php
$categories = get_the_category();
if (!empty($categories)) :
?>
<span class="category-tag"><?php echo esc_html($categories[0]->name); ?></span>
<?php endif; ?>
<h1 class="gradient-text"><?php the_title(); ?></h1>
<?php if (has_excerpt()) : ?>
<p class="excerpt" style="font-size: 1.25rem; color: #d1d5db; margin-bottom: 2rem;">
<?php the_excerpt(); ?>
</p>
<?php endif; ?>
<div style="color: #9ca3af; margin-bottom: 2rem;">
📅 Veröffentlicht am <?php echo get_the_date('j. F Y'); ?>
</div>
</header>
<div class="post-content">
<?php the_content(); ?>
</div>
</article>
<?php
// Related Posts
$categories = get_the_category();
if (!empty($categories)) {
$related_posts = new WP_Query(array(
'category__in' => array($categories[0]->term_id),
'post__not_in' => array(get_the_ID()),
'posts_per_page' => 3,
'post_status' => 'publish'
));
if ($related_posts->have_posts()) : ?>
<section style="border-top: 1px solid #1f2937; padding-top: 3rem; margin-top: 3rem;">
<h2 class="gradient-text" style="margin-bottom: 2rem;">Ähnliche Artikel</h2>
<div class="grid grid-3">
<?php while ($related_posts->have_posts()) : $related_posts->the_post(); ?>
<article class="card">
<span class="category-tag"><?php echo esc_html($categories[0]->name); ?></span>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<a href="<?php the_permalink(); ?>" class="card-link">
Weiterlesen →
</a>
</article>
<?php endwhile; ?>
</div>
</section>
<?php endif; wp_reset_postdata();
}
?>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>