98 lines
3.4 KiB
PHP
98 lines
3.4 KiB
PHP
<?php
|
||
/**
|
||
* 單篇文章模板(品牌專欄 / 媒體報導 / 開箱評測).
|
||
*
|
||
* @package MING
|
||
*/
|
||
|
||
get_header();
|
||
|
||
while ( have_posts() ) :
|
||
the_post();
|
||
$ming_cats = get_the_category();
|
||
$ming_cat = $ming_cats ? $ming_cats[0] : null;
|
||
$ming_catnm = $ming_cat ? $ming_cat->name : __( '文章', 'ming' );
|
||
?>
|
||
|
||
<section class="page-hero post-hero">
|
||
<div class="wrap">
|
||
<p class="eyebrow reveal"><?php echo esc_html( strtoupper( $ming_cat ? $ming_cat->slug : 'journal' ) ); ?></p>
|
||
<h1 class="h1 reveal"><?php the_title(); ?></h1>
|
||
<p class="sub reveal">
|
||
<?php if ( $ming_cat ) : ?><a class="post-cat" href="<?php echo esc_url( get_category_link( $ming_cat ) ); ?>"><?php echo esc_html( $ming_catnm ); ?></a> · <?php endif; ?>
|
||
<time datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo esc_html( get_the_date( 'Y.m.d' ) ); ?></time>
|
||
</p>
|
||
</div>
|
||
</section>
|
||
|
||
<article class="section post-body">
|
||
<div class="wrap post-wrap">
|
||
<?php if ( has_post_thumbnail() ) : ?>
|
||
<figure class="post-cover reveal">
|
||
<img src="<?php echo esc_url( get_the_post_thumbnail_url( null, 'large' ) ); ?>" alt="<?php the_title_attribute(); ?>">
|
||
</figure>
|
||
<?php endif; ?>
|
||
<div class="post-content reveal">
|
||
<?php the_content(); ?>
|
||
</div>
|
||
<div class="post-foot reveal">
|
||
<?php
|
||
ming_share_bar( array(
|
||
'title' => get_the_title() . '|MING 明命',
|
||
'text' => wp_trim_words( wp_strip_all_tags( get_the_content() ), 30, '…' ),
|
||
'label' => '分享這篇文章',
|
||
) );
|
||
?>
|
||
<div class="post-back">
|
||
<a class="textlink" href="<?php echo esc_url( ming_page_url_by_template( 'template-journal.php', get_permalink( get_option( 'page_for_posts' ) ) ) ); ?>">← 返回品牌專欄</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</article>
|
||
|
||
<?php
|
||
// 同分類其他文章.
|
||
if ( $ming_cat ) :
|
||
$ming_related = get_posts( array(
|
||
'post_type' => 'post',
|
||
'posts_per_page' => 3,
|
||
'category' => $ming_cat->term_id,
|
||
'post__not_in' => array( get_the_ID() ),
|
||
) );
|
||
if ( $ming_related ) :
|
||
?>
|
||
<section class="section journal-sec post-related">
|
||
<div class="wrap">
|
||
<div class="journal-head reveal">
|
||
<div>
|
||
<p class="eyebrow">MORE</p>
|
||
<h2 class="h2">更多「<?php echo esc_html( $ming_catnm ); ?>」</h2>
|
||
</div>
|
||
</div>
|
||
<div class="journal-grid">
|
||
<?php foreach ( $ming_related as $ming_post ) : ?>
|
||
<a class="jcard reveal" href="<?php echo esc_url( get_permalink( $ming_post ) ); ?>">
|
||
<div class="jimg">
|
||
<?php if ( has_post_thumbnail( $ming_post ) ) : ?>
|
||
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $ming_post, 'medium_large' ) ); ?>" alt="<?php echo esc_attr( get_the_title( $ming_post ) ); ?>" loading="lazy">
|
||
<?php endif; ?>
|
||
<span class="jcat"><?php echo esc_html( $ming_catnm ); ?></span>
|
||
</div>
|
||
<div class="jbody">
|
||
<time><?php echo esc_html( get_the_date( 'Y.m.d', $ming_post ) ); ?></time>
|
||
<h3><?php echo esc_html( get_the_title( $ming_post ) ); ?></h3>
|
||
<p><?php echo esc_html( wp_trim_words( wp_strip_all_tags( $ming_post->post_content ), 30, '…' ) ); ?></p>
|
||
<span class="jmore">閱讀全文 →</span>
|
||
</div>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<?php
|
||
endif;
|
||
endif;
|
||
endwhile;
|
||
|
||
get_footer();
|