您是否曾经想过允许用户在 WordPress 中订阅特定作者的文章?如果您运行一个多作者 WordPress 网站,那么您的用户可能希望订阅他们最喜欢的作者。在本文中,我们将向您展示如何允许用户在 WordPress 中订阅单个作者。
您是否曾经想过允许用户在 WordPress 中订阅特定作者的文章?如果您运行一个多作者 WordPress 网站,您的用户可能希望订阅他们最喜欢的作者。在本文中,我们将向您展示如何允许用户在 WordPress 中订阅单个作者。

为什么要在WordPress中添加订阅作者? (Why Add Subscribe to Authors in WordPress?)
Most large multi-author blogs like Huffington Post allow users to follow their favorite authors. You can offer this feature in your 多作者 WordPress 网站 as well.
大多数大型的多作者博客(如《赫芬顿邮报》)都允许用户关注自己喜欢的作者。 您也可以在多作者 WordPress 网站提供此功能。
WordPress generates RSS feeds for all authors, 类别, 标签, 自定义帖子类型, and comments on your site. However, your users can’t see these feeds link without knowing where to look.
WordPress会为您站点上的所有作者, 类别 , 标签 , 自定义帖子类型和评论生成RSS feed。 但是,您的用户不知道在哪里看就看不到这些提要链接。
作为网站所有者,您只需添加链接和订阅选项,以便用户可以订阅作者。
作为网站所有者,您只需添加链接和订阅选项,以便用户可以订阅作者。
说了这么多,我们来看看如何让用户在WordPress中轻松订阅作者。
话虽如此,让我们来看看如何让用户轻松订阅 WordPress 中的作者。
在WordPress中添加订阅作者功能 (Adding Subscribe to Authors Feature in WordPress)
您的 WordPress 网站上的所有作者都有自己的 RSS 提要。此 RSS 提要位于如下 URL:
WordPress 网站上的所有作者都有自己的 RSS 源。此 RSS 源位于以下 URL:
http://www.example.com/author/tom/feed/
http://www.example.com/author/tom/feed/
不要忘记将“tom”替换为您网站上现有作者的姓名。
不要忘记将“tom”替换为您网站上现有作者的姓名。
Many WordPress themes come with a section that displays author’s biographical information at the end of the article. You can add this HTML code in an 作者简介部分 to display a link to their RSS feed.
许多WordPress主题都带有一个部分,该部分在文章结尾显示作者的传记信息。 您可以在在作者简介部分添加此HTML代码,以显示指向其RSS feed的链接。
<a href="http://www.example.com/author/tom/feed">Subcribe Tom's Posts</a>

You can also automatically generate the link and use a 短代码 to manually insert it into posts.
您还可以自动生成链接,并使用短代码将其手动插入到帖子中。
First you need to add this code to your theme’s 函数.php file or a 特定于站点的插件.
首先,您需要将此代码添加到主题的函数.php文件或具体的于在网站的插件中 。
// Function to generate author's RSS feed link
function wpb_author_feed() {
$authorfeed = get_author_feed_link( get_the_author_id(), '');
$authorfeedlink = '<a href='. $authorfeed . '>Subscribe to get more posts from ' . get_the_author_meta( 'display_name') .'' ;
return $authorfeedlink;
}
// Create a shortcode to display the link
add_shortcode('authorfeed', 'wpb_author_feed');
// Enable shortcode execution in WordPress text widgets
add_filter('widget_text', 'do_shortcode');
You can now just use the shortcode [authorfeed]
in your posts, and it will automatically generate a link to the post author’s RSS feed. Feel free to customize the text you want to display for the link.
现在,您只需在帖子中使用简码[authorfeed]
,它将自动生成指向帖子作者的RSS feed的链接。 随意自定义要显示的链接文本。

在边栏中添加订阅作者链接 (Add a Subscribe to Author Link in the Sidebar)
We will be using the shortcode method we showed above to display a subscribe to author link in the sidebar of your WordPress blog. Simply go to 外观 » 小部件 page and add a text widget to your sidebar.
我们将使用上面显示的shortcode方法在WordPress博客的侧边栏中显示订阅作者链接。 只需转到外观 » 小部件页面,然后将一个文本小部件添加到侧边栏中。

You will need to add [authorfeed]
shortcode in the text area of the widget. After that, don’t forget to click on the save button to store widget settings.
您将需要在小部件的文本区域中添加[authorfeed]
简码。 之后,别忘了单击“保存”按钮来存储小部件设置。
您现在可以访问您的网站以查看正在运行的侧边栏。
现在您可以访问您的网站以查看侧边栏的运行情况。
这种方法的问题是它会在每个页面上显示小部件,包括主页、类别和标签档案等。
这种方法的问题是它会在每个页面上显示小部件,包括主页、类别和标签档案等。
You need to install and activate the 显示小部件 plugin. For more details, see our step by step guide on 如何安装 WordPress 插件.
您需要安装并激活显示小部件插件。 有关更多详细信息,请参阅有关如何安装 WordPress 插件步指南。
激活后,您需要访问小部件页面并编辑您之前添加的作者的提要小部件。
激活后,您需要访问“小部件”页面并编辑您之前添加的作者的提要小部件。

You will notice new options to control widget display on different pages of your site. Now you need to select “在选中的页面上显示”, and then check the single post option.
您会注意到新的选项来控制窗口小部件在站点的不同页面上的显示。 现在,您需要选择“在选定的页面上显示” ,然后选中“单个帖子”选项。
不要忘记单击“保存”按钮来存储您的小部件设置。
不要忘记单击“保存”按钮来存储您的小部件设置。
That’s all you can now visit your website to see your author subscription link in action. You can use a little CSS to create a button, or add an image icon as the subscription.
这就是您现在可以访问您的网站以查看您的作者订阅链接的全部内容。 您可以使用一些CSS创建按钮,或添加图像图标作为订阅。
We hope this article helped you learn how to allow users to subscribe to authors in WordPress. You may also want to see our guide on 如何修复 WordPress 中最常见的 RSS 提要错误.
我们希望本文能帮助您学习如何允许用户订阅WordPress中的作者。 您可能还想查看有关有关如何修复 WordPress 中最常见的 RSS 提要错误的指南 。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-allow-users-to-subscribe-to-authors-in-wordpress/