如何在WordPress文章下显示作者简介信息

你想在WordPress文章底部添加作者简介框吗?作者简介框通常可以展示博文作者信息如社交媒体资料等等。

许多Wordpress 主题允许网站管理员轻松的展示作者信息,然而一些主题可能并没有内置这个特色的功能,那么当你需要时,该如何添加呢,在这篇教程中我们将介绍多种方法轻松的显示作者简介信息,我们也分享一些技巧教大家如何定制化的显示此简介。

如何在Wordpress文章里添加作者简介信息

WordPress系统是当前市面上最佳的建站程序之一,因为它非常的灵活且可定制化选项,让我们可以轻松的展示自己需要的内容,市面上有许多不同的作者简介插件可以用,此文我们将介绍默认方法和2款不同的插件实现此功能。

方法1:使用当前默认Wordpress主题添加作者简介

如果你的WordPress主题支持在每篇文章的底部展示作者简介框,你可以简单且容易的使用此功能。

登入网站后台,导航到Users » All Users页面,在这里编辑你想更改显示的用户信息。

编辑作者

在资料编辑页,往下拉到‘Biographical info’文本框添加作者的简介,你也可以使用HTML代码手动添加作者的社交资料链接信息。

作者的头像通常通过Gravatar抓取,如果作者没有开通设置Gravatar头像,你可以请求作者上传一个自定义头像,点击更新作者信息保存后,post文章页面将显示如下作者信息

方法2:通过插件添加一个作者简介框

如果你的主题没有显示作者简介框选项,或者你想自定义显示,那么可以使用一个作者简介插件实现此功能。

首先,安装激活Author Bio Box 插件,导航到Settings » Author Bio Box页配置一些插件必要设置选项。

作者简介设置

在这,你可以设置颜色,头像照片尺寸,显示作者信息位置等选项,接来下导航到Users » All Users页,单击如下便捷链接。

进入资料编辑页后,你可以往下拉到‘Contact Info’ 区域,在这里你可以添加作者社交信息链接等。

此插件也支持展示社交媒体小图标,以上操作完成后,你可以鼠标选到‘Biographical Info’区域,在这里你你可以添加作者的简介,你可以可以使用HTML代码手动添加链接信息或其它HTML设置。

完成以上步骤,点击保存,即可以到前台看看是否添加正确。

方法3:使用Sidebar Widget添加显示作者信息

你是否想在侧边显示作者信息而不是在文章底部?如果你有这个需求的话,这个方法非常适合你的需要。

首先,安装 Meks Smart Author Widget 插件,激活后,导航到 Appearance » Widgets 页面,在这里你可以看到Meks Smart Author Widget 插件支持的一些可用的Widgets,你可可以添加Widgets到想显示作者简介的地方。

添加作者选项

Widgets有许多选项,记住最重要的一点是勾选Automatically detect author选项,点击保存按钮,即可以到前台看看是否添加正确。

方法4:手动添加代码实现作者简介显示

这个方法需要添加必要的代码到网站上,首先,添加以下代码到主题文件夹下的functions.php 里。

function wpb_author_info_box( $content ) {

global $post;

// Detect if it is a single post with a post author

if ( 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 name

if ( 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 href=”‘. $user_posts .'”>View all posts by ‘ . $display_name . ‘</a>’;  

// Check if author has a website in their profile

if ( ! empty( $user_website ) ) {

// Display author website link

$author_details .= ‘ | <a href=”‘ . $user_website .'” target=”_blank” rel=”nofollow”>Website</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 filter

add_action( ‘the_content’, ‘wpb_author_info_box’ );

// Allow HTML in author bio section

remove_filter(‘pre_user_description’, ‘wp_filter_kses’);

这个代码可以获取作者的信息且显示在Post文章下面,如果你需要编辑作者简介框的样式,你可以使用自定义添加CSS代码。

总结

添加作者简介的权威信息,有助于提高E-A-T谷歌优化排名因素,特别是对YLYM主题非常有用,以上就是4种添加作者简介的方法,第一种如果主题支持,非常简单,如果不支持,你可以根据第二和第三种添加作者简介插件实现,第四种需要一定的建站知识,适合比较数量使用Wordpress的用户使用,希望此教程对那些想在Wordpress文章底部或者侧边栏展示作者简介的用户有所帮助。