60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: AKSRT - Posts Navigation
|
|
* Template Post Type: page
|
|
*
|
|
* 文章导航页:分类+标签的导航聚合页。
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
get_header();
|
|
|
|
$categories = get_categories(['hide_empty' => true, 'orderby' => 'count', 'order' => 'DESC', 'number' => 20]);
|
|
$tags = get_tags(['hide_empty' => true, 'orderby' => 'count', 'order' => 'DESC', 'number' => 40]);
|
|
?>
|
|
|
|
<main id="main-content" class="container page-content-default" tabindex="-1">
|
|
<header class="page-header">
|
|
<h1 class="entry-title"><?php echo esc_html(get_the_title() ?: __('文章导航', 'aksrt')); ?></h1>
|
|
</header>
|
|
|
|
<div class="content-wrap">
|
|
<div class="content-layout content-layout--no-sidebar">
|
|
<div class="content-layout__primary">
|
|
<div class="aksrt-posts-navs container">
|
|
<?php if (!empty($categories)) : ?>
|
|
<section class="aksrt-posts-navs__section">
|
|
<h2 class="aksrt-posts-navs__heading"><?php esc_html_e('热门分类', 'aksrt'); ?></h2>
|
|
<div class="aksrt-posts-navs__cats">
|
|
<?php foreach ($categories as $cat) : ?>
|
|
<a href="<?php echo esc_url(get_category_link($cat->term_id)); ?>" class="aksrt-posts-navs__cat-chip">
|
|
<span class="aksrt-posts-navs__cat-name"><?php echo esc_html($cat->name); ?></span>
|
|
<span class="aksrt-posts-navs__cat-count"><?php echo esc_html($cat->count); ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($tags)) : ?>
|
|
<section class="aksrt-posts-navs__section">
|
|
<h2 class="aksrt-posts-navs__heading"><?php esc_html_e('热门标签', 'aksrt'); ?></h2>
|
|
<div class="aksrt-posts-navs__tags">
|
|
<?php foreach ($tags as $tag) : ?>
|
|
<a href="<?php echo esc_url(get_tag_link($tag->term_id)); ?>" class="aksrt-posts-navs__tag"><?php echo esc_html($tag->name); ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php
|
|
get_footer();
|