纯代码为WordPress文章结尾增加作者介绍模块
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

很多Wordpress主题都有作者介绍模块,一般位于文章结尾处,可以在每篇文章结尾对作者进行简单的介绍,提高作者曝光率。当然没有此功能的可以通过相关插件来实现,但蜗牛一直不提倡使用大量插件,因为大量插件的使用会增加服务器负担。那么我们是不是可以纯代码为自己的WordPress文章尾部增加作者介绍模块呢?答案是当然可以!下面蜗牛就为大家介绍一个方法,只需通过两段简单代码就可以为自己的博客文章尾部增加作者介绍模块。
一、添加作者信息板块:1、首先我们在主题中找到functions.php文件,并添加下面代码。
//添加作者信息板块——www.wn789.comfunction wpb_author_info_box( $content ) {global $post;// Detect if it is a single post with a post authorif ( is_single() && isset( $post->post_author ) ) {// Get author\'s display name$display_name = get_the_author_meta( \'display_name\', $post->post_author );// If display name is not available then use nickname as display nameif ( empty( $display_name ) )$display_name = get_the_author_meta( \'nickname\', $post->post_author );// Get author\'s biographical information or description$user_description = get_the_author_meta( \'user_description\', $post->post_author );// Get author\'s website URL$user_website = get_the_author_meta(\'url\', $post->post_author);// Get link to the author archive page$user_posts = get_author_posts_url( get_the_author_meta( \'ID\' , $post->post_author));if ( ! empty( $display_name ) )$author_details = \'<p class=\"author_name\">About \' . $display_name . \'</p>\';if ( ! empty( $user_description ) )// Author avatar and bio$author_details .= \'<p class=\"author_details\">\' . get_avatar( get_the_author_meta(\'user_email\') , 90 ) . nl2br( $user_description ). \'</p>\';$author_details .= \'<p class=\"author_links\"><a h=\"http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=wn789@vip.qq.com\" target=\"_blank\">点此给蜗牛发送邮件</a>\';// Check if author has a website in their profileif ( ! empty( $user_website ) ) {// Display author website link$author_details .= \' | <a h=\"tencent://message/?uin=490898739&Site=qq&Menu=yes\" target=\"_blank\" rel=\"nofollow\">广告投放QQ490898739</a></p>\';} else {// if there is no author website then just close the paragraph$author_details .= \'</p>\';}// Pass all this info to post content$content = $content . \'<footer class=\"author_bio_section\" >\' . $author_details . \'</footer>\';}return $content;}// Add our function to the post content filteradd_action( \'the_content\', \'wpb_author_info_box\' );// Allow HTML in author bio sectionremove_filter(\'pre_user_description\', \'wp_filter_kses\');2、在上面代码中我们可以根据自己需要进行简单修改。下面蜗牛已经列出:
“$author_details .= ‘<p class=”author_links”><a h=”http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=wn789@vip.qq.com” target=”_blank”>点此给蜗牛发送邮件</a>’; ”代码中的网址和汉字可以根据自己情况进行修改。“$author_details .= ‘ | <a h=”tencent://message/?uin=490898739&Site=qq&Menu=yes” target=”_blank” rel=”nofollow”>广告投放QQ490898739</a></p>’; ”代码中的网址和汉字可以根据自己情况进行修改。二、添加CSS样式:在主题文件中找到“main.css”文件。并把下面代码添加进去。
.author_bio_section{background: none repeat scroll 0 0 #F5F5F5;padding: 15px;border: 1px solid #ccc;}.author_name{font-size:16px;font-weight: bold;}.author_details img {border: 1px solid #D8D8D8;border-radius: 50%;float: left;margin: 0 10px 10px 0;}三、添加个人信息:
在“用户”-“我的个人资料”-个人说明栏填写你要显示的信息即可。这个信息可以根据自己需要填写,可以是介绍自己、也可以是广告内容。
四、效果显示:下图是蜗牛789添加作者信息板块后的效果。
猜你可能想看的VPS
- ShockHosting→$3.74 月 KVM-1G 200G 1TB全球[VPS测评]
- 搬瓦工原 DC8 机房不在接入 CN2 GT,建议切换 DC3 或选购搬全球[VPS测评]
- VM.DOG→$50 月 2GB 内存 60GB 空间 不限流量 1Gb虚拟空间(主机)
- tmwhost→$59.99 月 1GB 内存 30GB SSD 空间 虚拟空间(主机)
- 身字下面有六个甲是什么成语?全球[VPS测评]
- 便宜 VPS $20 年 512M 内存 10G SSD 1Gbps 不全球[VPS测评]
- 腾讯云采购季→上海云服务器年付 99 元起 2C8G5M 三年 1499全球[VPS测评]
- DMIT 两周年大促→美国 cn2 vps 消费返余额+送实物 三折起!美国VPS[主机]
- Linux 服务器局域网(内网)快速传输文件全球[VPS测评]
- 禁止 QQ 输入时自动转换表情的办法全球[VPS测评]
- Laravel 框架 Warning: require(.. vendo全球[VPS测评]
- smarthost→大硬盘 VPS 每 T 硬盘$4 月 洛杉矶 拉斯维全球[VPS测评]
- VPS 测评 搬瓦工 DC8 机房→KVM 512M 内存套餐全球[VPS测评]
- moonvm→香港 VPS HGC 线路 $45 月 KVM 2G 内存香港VPS[主机]
- 通过给WordPress文章添加3篇假的页码导航实现相关文章全球[VPS测评]
- RackNerd圣诞节1.5g内存20g硬盘2.5T大流量年付仅16.8全球[VPS测评]
- Yoho cloud 尼泊尔VPS 月付11€起 1C1G25G 不限流独立服务器[U]
- TheIDEAHosting-$5月付俄罗斯新西伯利亚 联通伯力同款线路全球[VPS测评]
- 如何更改WHMCS默认后台路径让WHMCS系统更安全全球[VPS测评]
- JGKVM(极光kvm),便宜香港VPS(5G防御秒解),极光互联vps香港VPS[主机]
- 晚点独家丨拼多多9月上线跨境电商平台,首站美国美国VPS[主机]
- 香港的云服务器值得租用吗?有什么好处?香港VPS[主机]
- 金斗云双12活动:全场8折起,美国圣何塞CN2 GIA高防VPS20元/美国VPS[主机]
- 虾皮跨境电商怎么样?虾皮跨境电商靠谱吗?全球[VPS测评]
- tmhhost:香港CN2/NNT,美国CN2 GIA VPS,韩国CN韩国VPS[主机]
- 蓝队云服务器怎么样?蓝队云服务器价格和优势是什么?全球[VPS测评]
- GigsGigsCloud:2核/4GB/50G空间/1TB流量/10M虚拟空间(主机)
- 美国信贷市场的痛苦将不亚于上世纪70年代的通胀时期美国VPS[主机]
- 极光KVM:1核/1G/40G/100Mbps/美国GIA,年付199元美国VPS[主机]
- 戈登云VPS,6折,充值送50%,香港cn2,美国cn云服务器,2核2G美国VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-129305.html











