文章内容
因为文章卡片和文章内容用的是同同一个函数,有些在文章中有用,只有只有在文章卡片中才有用,下面我会进行注明
# get_post_no
获取文章序号,这个只能用于首页文章卡片,比如我们可以控制每个文章卡片显示的图片方向,比如第一个是右边,第二个是左边
# post_title
文章标题,文章卡片和文章内容均可使用
# post_summer
文章描述,仅限文章卡片
# post_content
文章内容,只能用于文章内容
# post_id
文章id,文章卡片和文章内容均可使用
# get_post_id
获取文章id,这个是返回文章id,而不是直接打印,文章卡片和文章内容均可使用
# post_date
文章发布时间,文章卡片和文章内容均可使用
# post_good
文章点赞数,文章卡片和文章内容均可使用
# post_view
文章浏览量,文章卡片和文章内容均可使用
# post_image
文章背景,文章卡片和文章内容均可使用
# post_comment
文章评论数,文章卡片和文章内容均可使用
# post_modify
文章最后修改时间,只能在文章内中使用
# post_alipay
支付宝图片,可以用于打赏,只能在文章内中使用
# post_wechat
微信支付图片,可以用于打赏,只能在文章内中使用
# get_post_encrypt
判断文章是否加密,文章卡片和文章内容均可使用
# get_post_category
获取文章分类信息,只能在文章内容中使用。一个文章可能有多个分类,我们文章只取第一个即可,这里不需要担心文章分类为空的情况
<span class="category">
<a href="/?category=<?php echo get_post_category()[0]["link"]?>">
<?php echo get_post_category()[0]["name"]?>
</a>
</span>
1
2
3
4
5
2
3
4
5
# get_post_tags
获取文章标签信息,只能在文章内容中使用,例子:
<div class="pull-left">
<i class="fa fa-tags"></i>
<?php foreach (get_post_tags() as $tag){
echo "<a href='/?tag=${tag["link"]}'>${tag["name"]}</a>";
}?>
</div>
1
2
3
4
5
6
2
3
4
5
6
# get_post_is_top
文章是否为置定文章,只能在文章卡片中使用,这个返回布尔值,我们可以显示置顶的图片
# 分页相关
用于首页文章分页显示,有下面这几个函数
current_total
总页数current_count
总的数据条数get_current_count
或者总的数据条数,这个是直接返回数据条数,而不是打印current_current
当前第几页get_current_current
当前第几页,这个也是返回一个int类型,而不是直接打印current_size
每页有多少条数据
# get_post_comments
获取文章的评论信息
# get_index_category
这个可以用于主页显示所有的文章分类
文章分类的结构体如下
{
"parent": [
{
"count": 29,
"id": 8,
"link": "0200",
"name": "硬件奇谈"
}
],
"child": [
{
"id": 9,
"parent": 8,
"link": "0201",
"name": "STC51笔记"
},
{
"id": 10,
"parent": 8,
"link": "0202",
"name": "STM32笔记"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
我的处理逻辑,仅供参考
<?php $category = get_index_category();foreach ($category["parent"] as $parent): ?>
<div class="item">
<el-popover
placement="top-start"
width="100"
trigger="hover"
>
<?php foreach ($category["child"] as $child){
if($parent["id"]==$child["parent"]){
echo "<a href=\"/?category=${child["link"]}\">${child["name"]}</a>";
}
}
echo "<a slot=\"reference\" class=\"name\" href=\"javascript:void(0);\"><span>${parent["name"]}<em>${parent["count"]}</em></span></a>"?>
</el-popover>
</div>
<?php endforeach; ?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
编辑 (opens new window)
上次更新: 2021/08/01, 17:13:03