Bài viết này giới thiệu cách làm các trang Chuyên Mục, Thẻ, Tác Giả, Tìm Kiếm của giao diện Clean Blog, gồm archive.php, author.php, category.php và search.php.
Nội dung archive.php
<?php get_header(); ?> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <div class="site-heading text-center"> <h1> <?php if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('', false); } elseif (is_author()) { $title = '<span class="vcard">' . get_the_author() . '</span>'; } elseif (is_post_type_archive()) { $title = post_type_archive_title('', false); } elseif (is_tax()) { $title = single_term_title('', false); } else { $title = trim(single_month_title(' ', false)); } echo $title; ?> </h1> <hr class="small"> <span class="sub-heading">Danh sách các bài viết.</span> </div> </div> </div> </div> </header> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <?php include_once('includes/loop.php'); ?> </div> </div> </div> <?php get_footer(); ?>
Nội dung author.php
<?php get_header(); ?> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <div class="site-heading text-center"> <h1><?php the_author(); ?></h1> <hr class="small"> <span class="sub-heading">Danh sách các bài viết.</span> </div> </div> </div> </div> </header> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <?php include_once('includes/loop.php'); ?> </div> </div> </div> <?php get_footer(); ?>
Nội dung category.php
<?php get_header(); ?> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <div class="site-heading text-center"> <h1><?php echo single_cat_title('', false); ?></h1> <hr class="small"> <span class="sub-heading"> <?php $cat_desc = category_description(); if ($cat_desc) echo $cat_desc; else echo 'Danh sách các bài viết.'; ?> </span> </div> </div> </div> </div> </header> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <?php include_once('includes/loop.php'); ?> </div> </div> </div> <?php get_footer(); ?>
Nội dung search.php
Trang này chỉ để sẵn phòng trường hợp tìm kiếm bằng liên kết, vì giao diện này không có chức năng này.
<?php get_header(); ?> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <div class="site-heading text-center"> <h1>Từ khóa: <?php echo get_search_query(); ?></h1> <hr class="small"> <span class="sub-heading">Danh sách các bài viết tìm được.</span> </div> </div> </div> </div> </header> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <?php include_once('includes/loop.php'); ?> </div> </div> </div> <?php get_footer(); ?>
Các tập tin này đều giống nhau, chỉ khác ở phần tiêu đề.