121 lines
3.4 KiB
PHP
121 lines
3.4 KiB
PHP
<?php
|
||
/**
|
||
* The main template file
|
||
*
|
||
* Responsive 1/2/3-column post grid, sticky hero for top-pinned posts,
|
||
* customiser-driven welcome banner, and pagination.
|
||
*
|
||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
||
*
|
||
* @package CyyWordpress
|
||
*/
|
||
|
||
get_header();
|
||
?>
|
||
|
||
<div id="primary" class="content-area">
|
||
<main id="main" class="site-main" role="main">
|
||
|
||
<?php
|
||
// Welcome banner – controlled via Customizer.
|
||
$show_banner = get_theme_mod( 'cyywordpress_show_welcome_banner', true );
|
||
$welcome_text = get_theme_mod( 'cyywordpress_welcome_text', __( '欢迎来到这!Hello everyone.', 'cyywordpress' ) );
|
||
|
||
if ( $show_banner && ( is_home() || is_front_page() ) ) :
|
||
?>
|
||
<div class="notification is-primary welcome-banner" data-customizer="cyywordpress_welcome_text">
|
||
<?php echo esc_html( $welcome_text ); ?>
|
||
</div>
|
||
<?php
|
||
endif;
|
||
?>
|
||
|
||
<nav class="breadcrumb" aria-label="<?php esc_attr_e( '面包屑导航', 'cyywordpress' ); ?>">
|
||
<ul>
|
||
<li>
|
||
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
|
||
<span class="icon is-small"><i class="fa-solid fa-house" aria-hidden="true"></i></span>
|
||
<span><?php esc_html_e( '首页', 'cyywordpress' ); ?></span>
|
||
</a>
|
||
</li>
|
||
<?php if ( is_home() && ! is_front_page() ) : ?>
|
||
<li class="is-active">
|
||
<a href="#" aria-current="page"><?php single_post_title(); ?></a>
|
||
</li>
|
||
<?php endif; ?>
|
||
</ul>
|
||
</nav>
|
||
|
||
<?php if ( have_posts() ) : ?>
|
||
|
||
<?php
|
||
// Separate sticky posts for hero treatment.
|
||
$sticky_ids = get_option( 'sticky_posts', array() );
|
||
$hero_printed = false;
|
||
?>
|
||
|
||
<div class="posts-grid columns is-multiline">
|
||
<?php
|
||
while ( have_posts() ) :
|
||
the_post();
|
||
|
||
// Sticky → hero card (full-width), only first sticky.
|
||
if ( is_sticky() && ! $hero_printed && is_home() && ! is_paged() ) :
|
||
$hero_printed = true;
|
||
echo '<div class="column is-12 post-card--hero">';
|
||
get_template_part( 'template-parts/content', get_post_type() );
|
||
echo '</div>';
|
||
else :
|
||
echo '<div class="column is-12-mobile is-6-tablet is-4-desktop">';
|
||
get_template_part( 'template-parts/content', get_post_type() );
|
||
echo '</div>';
|
||
endif;
|
||
|
||
endwhile;
|
||
?>
|
||
</div><!-- .posts-grid -->
|
||
|
||
<div class="posts-pagination">
|
||
<?php the_posts_pagination(
|
||
array(
|
||
'mid_size' => 2,
|
||
'prev_text' => '<i class="fa-solid fa-chevron-left" aria-hidden="true"></i> ' . esc_html__( '上一页', 'cyywordpress' ),
|
||
'next_text' => esc_html__( '下一页', 'cyywordpress' ) . ' <i class="fa-solid fa-chevron-right" aria-hidden="true"></i>',
|
||
)
|
||
); ?>
|
||
</div>
|
||
|
||
<?php else : ?>
|
||
<?php get_template_part( 'template-parts/content', 'none' ); ?>
|
||
<?php endif; ?>
|
||
|
||
</main><!-- #main -->
|
||
</div><!-- #primary -->
|
||
|
||
<?php
|
||
get_sidebar();
|
||
get_footer();
|
||
|
||
<br>
|
||
<br>
|
||
<!-- <div class="columns" style=" margin-bottom: 25px;">-->
|
||
<!-- <div class="column is-narrow">-->
|
||
<!-- <div class="box" style="width: 200px;">-->
|
||
<!-- <p class="title is-5">预留位1</p>-->
|
||
<!-- <p class="subtitle">预留文字.</p>-->
|
||
<!-- </div>-->
|
||
<!-- </div>-->
|
||
<!-- <div class="column">-->
|
||
<!-- <div class="box">-->
|
||
<!-- <p class="title is-5">预留位2</p>-->
|
||
<!-- <p class="subtitle">预留文字.</p>-->
|
||
<!-- </div>-->
|
||
<!-- </div>-->
|
||
<!-- </div>-->
|
||
|
||
|
||
|
||
<?php
|
||
get_sidebar();
|
||
get_footer();
|