update
This commit is contained in:
@@ -2,10 +2,8 @@
|
||||
/**
|
||||
* The main template file
|
||||
*
|
||||
* This is the most generic template file in a WordPress theme
|
||||
* and one of the two required files for a theme (the other being style.css).
|
||||
* It is used to display a page when nothing more specific matches a query.
|
||||
* E.g., it puts together the home page when no home.php file exists.
|
||||
* 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/
|
||||
*
|
||||
@@ -14,69 +12,89 @@
|
||||
|
||||
get_header();
|
||||
?>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<!-- <h1 class="title">
|
||||
<?php /*bloginfo( 'name' ); */?>
|
||||
</h1>-->
|
||||
<p class="subtitle">
|
||||
<?php bloginfo( 'description' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<br>
|
||||
<div class="notification is-primary">
|
||||
欢迎来到这! <strong>Hello everyone.</strong>
|
||||
</div>
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main" role="main">
|
||||
|
||||
<nav class="breadcrumb" aria-label="breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" >
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-home" aria-hidden="true"></i>
|
||||
</span>
|
||||
<span>首页</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?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 if ( have_posts() ) : ?>
|
||||
|
||||
if ( is_home() && ! is_front_page() ) :
|
||||
?>
|
||||
<p class="title is-4"><?php single_post_title(); ?></p>article
|
||||
<?php
|
||||
endif;
|
||||
<?php
|
||||
// Separate sticky posts for hero treatment.
|
||||
$sticky_ids = get_option( 'sticky_posts', array() );
|
||||
$hero_printed = false;
|
||||
?>
|
||||
|
||||
/* Start the Loop */
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
<div class="posts-grid columns is-multiline">
|
||||
<?php
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
|
||||
/*
|
||||
* Include the Post-Type-specific template for the content.
|
||||
* If you want to override this in a child theme, then include a file
|
||||
* called content-___.php (where ___ is the Post Type name) and that will be used instead.
|
||||
*/
|
||||
get_template_part( 'template-parts/content', get_post_type() );
|
||||
// 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;
|
||||
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>
|
||||
|
||||
the_posts_navigation();
|
||||
<?php else : ?>
|
||||
<?php get_template_part( 'template-parts/content', 'none' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
else :
|
||||
|
||||
get_template_part( 'template-parts/content', 'none' );
|
||||
|
||||
endif;
|
||||
?>
|
||||
</main><!-- #main -->
|
||||
</div><!-- #primary -->
|
||||
|
||||
<?php
|
||||
get_sidebar();
|
||||
get_footer();
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user