84 lines
3.3 KiB
PHP
84 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* Fallback template (posts / archives / search).
|
|
*
|
|
* @package MING
|
|
*/
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<main class="section">
|
|
<div class="wrap">
|
|
<?php if ( have_posts() ) : ?>
|
|
<?php if ( ! is_singular() ) : ?>
|
|
<p class="eyebrow">MING</p>
|
|
<h2 class="h2"><?php echo is_search() ? esc_html__( '搜尋結果', 'ming' ) : esc_html( get_the_archive_title() ? wp_strip_all_tags( get_the_archive_title() ) : __( '文章', 'ming' ) ); ?></h2>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( is_category() ) : ?>
|
|
<div class="archive-journal-grid">
|
|
<?php
|
|
while ( have_posts() ) :
|
|
the_post();
|
|
$ming_acat = get_the_category();
|
|
$ming_aname = $ming_acat ? $ming_acat[0]->name : '';
|
|
?>
|
|
<a class="jcard" href="<?php the_permalink(); ?>">
|
|
<div class="jimg">
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
|
<img src="<?php echo esc_url( get_the_post_thumbnail_url( null, 'medium_large' ) ); ?>" alt="<?php the_title_attribute(); ?>" loading="lazy">
|
|
<?php endif; ?>
|
|
<?php if ( $ming_aname ) : ?><span class="jcat"><?php echo esc_html( $ming_aname ); ?></span><?php endif; ?>
|
|
</div>
|
|
<div class="jbody">
|
|
<time><?php echo esc_html( get_the_date( 'Y.m.d' ) ); ?></time>
|
|
<h3><?php the_title(); ?></h3>
|
|
<p><?php echo esc_html( wp_trim_words( wp_strip_all_tags( get_the_content() ), 30, '…' ) ); ?></p>
|
|
<span class="jmore">閱讀全文 →</span>
|
|
</div>
|
|
</a>
|
|
<?php
|
|
endwhile;
|
|
?>
|
|
</div>
|
|
<?php the_posts_pagination( array( 'prev_text' => __( '上一頁', 'ming' ), 'next_text' => __( '下一頁', 'ming' ) ) ); ?>
|
|
<?php else : ?>
|
|
<div style="max-width:46em;margin-top:2.5rem">
|
|
<?php
|
|
while ( have_posts() ) :
|
|
the_post();
|
|
?>
|
|
<article <?php post_class(); ?> style="margin-bottom:3rem">
|
|
<h3 style="font-family:var(--serif);font-weight:600;font-size:1.3rem;letter-spacing:.1em;color:var(--green-deep)">
|
|
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
|
</h3>
|
|
<div style="font-size:.78rem;letter-spacing:.2em;color:var(--muted);margin:.4rem 0 1rem"><?php echo esc_html( get_the_date() ); ?></div>
|
|
<div class="entry-content">
|
|
<?php is_singular() ? the_content() : the_excerpt(); ?>
|
|
</div>
|
|
</article>
|
|
<?php
|
|
endwhile;
|
|
|
|
the_posts_pagination(
|
|
array(
|
|
'prev_text' => __( '上一頁', 'ming' ),
|
|
'next_text' => __( '下一頁', 'ming' ),
|
|
)
|
|
);
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php else : ?>
|
|
<p class="eyebrow">404</p>
|
|
<h2 class="h2"><?php esc_html_e( '找不到內容', 'ming' ); ?></h2>
|
|
<p style="margin-top:1.5rem;color:var(--muted)"><?php esc_html_e( '這裡沒有任何內容,請回到首頁。', 'ming' ); ?></p>
|
|
<p style="margin-top:2rem"><a class="cta" style="display:inline-block;padding:.95rem 3.2rem;border:1px solid var(--green-deep);font-size:.82rem;letter-spacing:.4em;color:var(--green-deep)" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( '回首頁', 'ming' ); ?></a></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</main>
|
|
|
|
<?php
|
|
get_footer();
|