1 Star 4 Fork 1

gallanthunter/wp-theme-beginner

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index copy 2.php 5.72 KB
一键复制 编辑 原始数据 按行查看 历史
gallanthunter 提交于 2023-01-12 21:21 . 修改首页布局
<?php
/*
* @Filename : index.php
* @Description :
* @Author : Zhang Zhijun <gallanthunter@163.com>
* @Copyright : Copyright (c) 2022 by chahuawu.com, All Rights Reserved.
* @License : Mulan PubL v2
* @Link : https://chahuawu.com
* @CreateTime : 2022-12-17 20:57:28
* @LastModifyTime: 2023-01-11 22:07:26
*/
get_header();
?>
<div class="bgn-container bgn-m-auto bgn-max-w-screen-xl bgn-leading-relaxed divide-y divide-fuchsia-300">
<!-- 推荐文章 -->
<div class="bgn-py-4">
<h1>精选文章</h1>
</div>
<div class="bgn-w-full bgn-flex bgn-flex-warp bgn-border-b bgn-border-gray-300">
<div class=""></div>
<!-- 图片/幻灯片 -->
<div class="bgn-w-full md:bgn-w-1/2">
</div>
<!-- 推荐文章 -->
<div class="bgn-w-full md:bgn-w-1/2 bgn-flex bgn-flex-col">
</div>
</div>
<!-- 最新文章 -->
<div class="bgn-py-4">
<h1>最新发布</h1>
</div>
<div class="bgn-w-full bgn-flex bgn-flex-wrap bgn-py-4 bgn-border-b bgn-border-gray-300">
<?php
$args = array(
'ignore_sticky_posts' => 1,
'orderby' => 'date',
'showposts' => 4
);
query_posts($args);
while (have_posts()) :
the_post();
?>
<article class="bgn-w-full md:bgn-w-1/2 bgn-pt-4 bgn-pr-4">
<!-- 文章标题 -->
<div class="bgn-pb-2">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></h2>
</div>
<!-- 文章摘要 -->
<div class="bgn-font-light bgn-excerpt">
<?php
$excerpt = $post->post_excerpt;
if (empty($excerpt)) {
echo strip_tags(apply_filters('the_content', strip_shortcodes($post->post_content)));
} else {
echo strip_tags(apply_filters('the_excerpt', strip_shortcodes($post->post_excerpt)));
}
?>
</div>
<!-- 文章信息 -->
<div class="bgn-p-2">
<?php if (!is_category()) {
$category = get_the_category();
if ($category[0]) {
?>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-sharp fa-solid fa-rectangle-list bgn-text-gray-400"></i>
<a href="<?php echo get_category_link($category[0]->term_id) ?>"><?php echo $category[0]->cat_name ?></a>
</span>
<?php }
}; ?>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-solid fa-clock bgn-text-gray-400"></i>
<?php echo timeago(get_gmt_from_date(get_the_time('Y-m-d G:i:s'))) ?>
</span>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-solid fa-eye bgn-text-gray-400"></i>
<?php deel_views('浏览'); ?>
</span>
</div>
</article>
<?php
endwhile;
wp_reset_query(); ?>
</div>
<!-- 热门文章 -->
<div class="bgn-py-4">
<h1>热门文章</h1>
</div>
<div class="bgn-w-full bgn-flex bgn-flex-wrap bgn-pb-4 bgn-b-border bgn-border-gray-500">
<?php
$args = array(
'ignore_sticky_posts' => 1,
'orderby' => 'comment_count',
'showposts' => 6
);
query_posts($args);
while (have_posts()) :
the_post();
?>
<article class="bgn-w-full md:bgn-w-1/3 bgn-py-4 bgn-pr-4">
<!-- 文章标题 -->
<div class="bgn-pb-2">
<h2><a href="<?php the_permalink() ?>"> <?php the_title(); ?></h2>
</div>
<!-- 文章摘要 -->
<div class="bgn-font-light bgn-excerpt">
<?php
$excerpt = $post->post_excerpt;
if (empty($excerpt)) {
echo strip_tags(apply_filters('the_content', strip_shortcodes($post->post_content)));
} else {
echo strip_tags(apply_filters('the_excerpt', strip_shortcodes($post->post_excerpt)));
}
?>
</div>
<!-- 文章信息 -->
<div class="bgn-p-2">
<?php if (!is_category()) {
$category = get_the_category();
if ($category[0]) {
?>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-sharp fa-solid fa-rectangle-list bgn-text-gray-400"></i>
<a href="<?php echo get_category_link($category[0]->term_id) ?>"> <?php echo $category[0]->cat_name ?></a>
</span>
<?php }
}; ?>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-solid fa-clock bgn-text-gray-400"></i>
<?php echo timeago(get_gmt_from_date(get_the_time('Y-m-d G:i:s'))) ?>
</span>
<span class="bgn-pr-4 bgn-text-sm">
<i class="fa-solid fa-eye bgn-text-gray-400"></i>
<?php deel_views('浏览'); ?>
</span>
</div>
</article>
<?php
endwhile;
wp_reset_query(); ?>
</div>
</div>
<!-- footer -->
<?php get_footer(); ?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/gallanthunter/wp-theme-beginner.git
git@gitee.com:gallanthunter/wp-theme-beginner.git
gallanthunter
wp-theme-beginner
wp-theme-beginner
master

搜索帮助