使用困难可联系站长解决部署问题
如果您的网站是动漫类型的,注册的用户也多,那么这个功能可以在一定程度上增加网站的积极性。
部署较为繁琐,可联系站长解决,QQ:1355471563
教程开始
两个PHP文件,一个SQL数据库。
在functions.php的底部添加functions.php中的代码
将page-xunzhang.php文件上传到主题根目录。
将xunzhang.sql文件导入到数据库,会产生两个表:
- wp_customize(勋章数据表)
- wp_customize_type(勋章类别表)
添加徽章申请页面
新建页面,名称为xunzhangzhongxin,选择模板勋章申请
添加徽章


徽章的调用
Modules → Common→ Common.php第205行

其他位置可这样用
$n_author_id = get_post_field ('post_author', get_the_ID() );
$xunzhang = get_the_xunzhang_id($n_author_id);
<?php
$n_xz = ''.$xunzhang.'';
echo "$n_xz";
?>
带title并显示所有勋章
<div class="post-meta-xunzhang">
<?php
$user = get_the_author_meta('xunzhang_of_birth', $user_id);
if (!empty($user)) {
foreach ($user as $v) {
$tmp_arr[] = implode(',', $v);
}
$id = implode(',', $tmp_arr);
$type2 = $wpdb->get_results('SELECT * FROM wp_customize where id in (' . $id . ') order by id,sort', 'ARRAY_A');
foreach ($type2 as $v) {
echo "<a><img src='{$v['imgurl']}' title='{$v['name']}'></a>";
}
}
?>
</div>
<style type="text/css">
.post-meta-xunzhang {
position: absolute;
float: left;
margin-left: 6em;
}
.post-meta-xunzhang img {
width: 32px;
}
</style>