纯代码为WordPress文章结尾增加作者介绍模块

纯代码为WordPress文章结尾增加作者介绍模块,第1张

纯代码为WordPress文章结尾增加作者介绍模块

很多Wordpress主题往往都有作者介绍模块,一般位于文章内容的末尾,可以在每章末尾对作者进行简要介绍,增强作者的曝光度。不具备该功能的自然可以按照相关插件保留,但是傲云并没有提倡应用很多插件,因为很多插件的应用会增强网络服务器的承诺。那么,人们可以简单地在他们的WordPress文章的结尾编码来推广作者介绍模块吗?答案自然是!下面小乌龟给大家介绍一个方法。只要按照每个简单的代码,就可以升级博文末尾的作者介绍模块。

一、加上作者信息版块:

1.人们首先在主题中寻找functions.php文档,并添加了以下代码。

//加上作者信息版块——www.veidc.com functionwpb_author_info_box($content){ global$post; //Detectifitisasinglepostwithapostauthor if(is_single()&&isset($post->post_author)){ //Getauthor'sdisplayname $display_name=get_the_author_meta('display_name',$post->post_author); //Ifdisplaynameisnotavailablethenusenicknameasdisplayname if(empty($display_name)) $display_name=get_the_author_meta('nickname',$post->post_author); //Getauthor'sbiographicalinformationordescription $user_description=get_the_author_meta('user_description',$post->post_author); //Getauthor'swebsiteURL $user_website=get_the_author_meta('url',$post->post_author); //Getlinktotheauthorarchivepage $user_posts=get_author_posts_url(get_the_author_meta('ID',$post->post_author)); if(!empty($display_name)) $author_details='<pclass="author_name">有关'.$display_name.'</p>'; if(!empty($user_description)) //Authoravatarandbio $author_details.='<pclass="author_details">'.get_avatar(get_the_author_meta('user_email'),90).nl2br($user_description).'</p>'; $author_details.='<pclass="author_links"><ahref="https://t.me/veidc"target="_blank">点此添加传真群(强烈推荐)</a>'; //Checkifauthorhasawebsiteintheirprofile if(!empty($user_website)){ //Displayauthorwebsitelink $author_details.='|<ahref="https://shang.qq.com/wpa/qunwpa?idkey=0454d99933e5e5e045498a44255359c5e1be4e3f18c4522ad40bcd306c6b0d48"target="_blank"rel="nofollow">QQ沟通交流群:281562063</a></p>'; }else{ //ifthereisnoauthorwebsitethenjustclosetheparagraph $author_details.='</p>'; } //Passallthisinfotopostcontent $content=$content.'<footerclass="author_bio_section">'.$author_details.'</footer>'; } return$content; } //Addourfunctiontothepostcontentfilter add_action('the_content','wpb_author_info_box'); //AllowHTMLinauthorbiosection remove_filter('pre_user_description','wp_filter_kses');

2.在上面的编码中,人们可以根据自己的需要进行简单的修改。已经列出如下:

$author_details.='<p class="author_links"><a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&[email protected]" target="_blank">点此给VEIDC评测邮件发送</a>';$author_details.='|<a href="https://wpa.qq.com/msgrd?v=3&uin=9591050&site=qq&menu=yes" target="_blank" rel="nofollow">广告营销QQ:9591050</a></p>';编码中的网站地址和中国汉字能够依据自身状况开展改动。 二、加上CSS款式:

在主题文档中查找“main.css”文档。并添加以下代码。

.author_bio_section{ background:nonerepeatscroll00#F5F5F5; padding:15px; border:1pxsolid#ccc; } .author_name{ font-size:16px; font-weight:bold; } .author_detailsimg{ border:1pxsolid#D8D8D8; border-radius:50%; float:left; margin:010px10px0; } 三、加上本人信息:

只需在“客户”-“我的个人信息”-“个人描述”一栏填写你能显示的信息即可。这些信息可以根据自身填写,可以是对自身的介绍,也可以是广告词的内容。

四、实际效果显示信息:

下图是添加作者信息部分后的实际效果。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/744460.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-29
下一篇 2022-04-29

发表评论

登录后才能评论

评论列表(0条)

保存