WowPress-Tailwind/theme/template-parts/content/content.php

41 lines
1.3 KiB
PHP
Raw Normal View History

2024-04-15 16:00:49 +02:00
<?php
2024-04-22 15:38:22 +02:00
2024-04-15 16:00:49 +02:00
/**
* Template part for displaying posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WowPress
*/
2024-04-22 15:38:22 +02:00
use WoWPress\Models\User;
$author = User::find(get_the_author_meta('ID'));
2024-04-15 16:00:49 +02:00
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
2024-04-23 00:44:42 +02:00
<div class="post-wrapper" style="--author-class:var(--color-<?=$author->color?>)">
2024-04-22 15:38:22 +02:00
<div class="post-title">
2024-04-26 17:47:19 +02:00
<h1 class="underline"><a href="<?=the_permalink()?>"><?php the_title() ?></a></h1>
2024-04-22 15:38:22 +02:00
</div>
2024-04-15 16:00:49 +02:00
<div class="post-content"><?php the_content() ?></div>
2024-04-22 15:38:22 +02:00
<div class="post-day"><?= get_the_date('d') ?></div>
<div class="post-month"><?= get_the_date('F') ?></div>
2024-04-15 16:00:49 +02:00
<?php
$category = get_the_category();
$category = array_pop($category);
2024-04-22 15:38:22 +02:00
$color = get_term_meta($category->term_id, 'color', true);
2024-04-15 16:00:49 +02:00
?>
2024-04-22 15:38:22 +02:00
<div class="post-category ribbon" style="--color-ribbon:#<?= ctype_xdigit($color) ? $color : 'fff' ?>"><span><?= $category->name ?></span></div>
2024-04-23 00:44:42 +02:00
<div class="post-avatar"><img src="<?= $author->avatar ?>"></div>
2024-04-15 16:00:49 +02:00
<div class="post-author">
2024-04-22 15:38:22 +02:00
<?php if (current_user_can('edit_post', $post->ID)) : ?>
<a href="<?= get_edit_post_link($post->ID) ?>">
2024-04-23 00:44:42 +02:00
<?= $author->username ?>
2024-04-22 15:38:22 +02:00
</a>
<?php else : ?>
2024-04-23 00:44:42 +02:00
<?= $author->username ?>
2024-04-22 15:38:22 +02:00
<?php endif; ?>
</div>
</article><!-- #post-${ID} -->