99 lines
3.9 KiB
PHP
99 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* 404 template.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
get_header();
|
|
|
|
$search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索', 'aksrt');
|
|
$hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
|
|
|
|
$hot_query = new WP_Query([
|
|
'post_type' => 'post',
|
|
'posts_per_page' => 5,
|
|
'post_status' => 'publish',
|
|
'orderby' => 'comment_count',
|
|
'order' => 'DESC',
|
|
'no_found_rows' => true,
|
|
'ignore_sticky_posts' => true,
|
|
]);
|
|
|
|
$top_cats = get_terms([
|
|
'taxonomy' => 'category',
|
|
'orderby' => 'count',
|
|
'order' => 'DESC',
|
|
'number' => 6,
|
|
'hide_empty' => true,
|
|
]);
|
|
?>
|
|
|
|
<main id="main-content" class="site-main content-shell content-shell--page" tabindex="-1">
|
|
<section class="error-hero" aria-labelledby="error-title">
|
|
<div class="term-page-header__body term-page-header__body--error">
|
|
<div>
|
|
<p class="error-hero__icon" aria-hidden="true">
|
|
<i class="fa fas fa-compass"></i>
|
|
</p>
|
|
<p class="error-hero__code" id="error-title">404</p>
|
|
<h1 class="error-hero__title"><?php esc_html_e('页面未找到', 'aksrt'); ?></h1>
|
|
<p class="error-hero__desc">
|
|
<?php esc_html_e('你访问的页面不存在或已被删除。试试搜索,或者从下方常用入口继续浏览。', 'aksrt'); ?>
|
|
</p>
|
|
</div>
|
|
<?php if (function_exists('aksrt_render_admin_quick_link')) { aksrt_render_admin_quick_link('page-display/other', __('404 页设置', 'aksrt')); } ?>
|
|
</div>
|
|
|
|
<form role="search" method="get" class="error-hero__search" action="<?php echo esc_url(home_url('/')); ?>">
|
|
<span class="error-hero__search-icon" aria-hidden="true">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
|
</span>
|
|
<label class="screen-reader-text" for="error-search-input"><?php esc_html_e('搜索', 'aksrt'); ?></label>
|
|
<input type="search" id="error-search-input" name="s" placeholder="<?php echo esc_attr($search_placeholder); ?>" autocomplete="off">
|
|
<button type="submit" class="btn-primary btn-sm"><?php esc_html_e('搜索', 'aksrt'); ?></button>
|
|
</form>
|
|
<?php aksrt_render_search_hot_keywords($hot_keywords, 'aksrt-search-hot-keywords'); ?>
|
|
|
|
<div class="error-hero__actions">
|
|
<a href="<?php echo esc_url(home_url('/')); ?>" class="btn-primary"><?php esc_html_e('返回首页', 'aksrt'); ?></a>
|
|
<a href="javascript:history.back()" class="btn-outline"><?php esc_html_e('返回上一页', 'aksrt'); ?></a>
|
|
</div>
|
|
</section>
|
|
|
|
<?php if (!empty($top_cats) && !is_wp_error($top_cats)) : ?>
|
|
<section class="error-section" aria-label="<?php esc_attr_e('热门分类', 'aksrt'); ?>">
|
|
<h2 class="error-section__title"><?php esc_html_e('热门分类', 'aksrt'); ?></h2>
|
|
<div class="error-section__chips">
|
|
<?php foreach ($top_cats as $cat) : ?>
|
|
<a class="error-section__chip" href="<?php echo esc_url(get_category_link($cat->term_id)); ?>">
|
|
<?php echo esc_html($cat->name); ?>
|
|
<span><?php echo (int) $cat->count; ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($hot_query->have_posts()) : ?>
|
|
<section class="error-section" aria-label="<?php esc_attr_e('热门内容', 'aksrt'); ?>">
|
|
<h2 class="error-section__title"><?php esc_html_e('热门内容', 'aksrt'); ?></h2>
|
|
<ul class="error-section__list">
|
|
<?php while ($hot_query->have_posts()) : $hot_query->the_post(); ?>
|
|
<li>
|
|
<a href="<?php the_permalink(); ?>">
|
|
<span class="error-section__list-title"><?php the_title(); ?></span>
|
|
<span class="error-section__list-meta"><?php echo esc_html(get_the_date('Y-m-d')); ?></span>
|
|
</a>
|
|
</li>
|
|
<?php endwhile; wp_reset_postdata(); ?>
|
|
</ul>
|
|
</section>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<?php
|
|
get_footer();
|