
WordPress 电子邮件订阅
WordPress comes with built-in taxonomies, 类别和标签, that allows you to organize your content. Almost every WordPress user has used categories and tags to sort their content, but most users don’t know that categories, tags, and custom taxonomies each have their own RSS feeds (什么是RSS?). Why is that useful? Well, these topic specific RSS feeds allow your users to only subscribe to the content they are most interested in. In this article, we will show you how to allow users to subscribe to categories in WordPress.
WordPress带有内置的分类法, 类别和标签 ,可让您组织内容。 几乎每个WordPress用户都使用类别和标签对内容进行排序,但是大多数用户不知道类别,标签和自定义分类法各自都有自己的RSS feed( 什么是RSS? )。 为什么这样有用? 好了,这些主题特定的RSS feed允许您的用户只订阅他们最感兴趣的内容。在本文中,我们将向您展示如何允许用户订阅WordPress中的类别。
WordPress中类别特定的RSS Feed (Category Specific RSS Feed in WordPress)
By default, WordPress enables topic specific RSS feed for each category, tag, and 自定义分类法. Most smart browsers will detect and display the RSS feed URL of the page. You can access the category specific RSS feed by simply adding /feed/
to the end of category URL. For example:
默认情况下,WordPress为每个类别,标签和自定义分类法启用特定于主题的RSS feed。 大多数智能浏览器都会检测并显示页面的RSS feed URL。 您只需在类别URL的末尾添加/feed/
即可访问特定于类别的RSS feed。 例如:
https://www.wpbeginner.com/category/wp-tutorials/feed/
https://www.wpbeginner.com/category/wp-tutorials /feed/
现在,允许用户订阅 WordPress 中的类别的最简单方法是让他们了解该类别。您可以在每个类别页面上添加类别 RSS 源链接。您还可以添加其他订阅选项,例如 feedly 和博客行。最后但并非最不重要的一点是,您可以允许他们通过电子邮件订阅类别。让我们详细看看所有这些选项。
现在,允许用户订阅 WordPress 中的类别的最简单方法就是让他们知道。您可以在每个类别页面上添加类别 RSS 源链接。您还可以添加其他订阅选项,例如 feed 和博客行。最后但并非最不重要的一点是,您可以允许他们通过电子邮件订阅类别。让我们详细了解所有这些选项。
在类别页面上添加RSS订阅链接 (Adding a RSS Subscription Link on Category Pages)
Lets start with adding a simple RSS subscription link on category pages. First thing you need to do is go inside your theme’s folder and find the file category.php
. If you don’t see category.php, then look for archive.php
. If you don’t see either of those, then there is a strong chance that you are using a WordPress 主题框架, and this article will not be as helpful for you.
让我们从在类别页面上添加简单的RSS订阅链接开始。 您需要做的第一件事是进入主题文件夹,然后找到文件category.php
。 如果没有看到category.php,请寻找archive.php
。 如果您没有看到任何一个,则很有可能您正在使用WordPress 主题框架 ,并且本文对您没有帮助。
现在,如果您的主题有一个category.php 文件,则只需在要显示订阅链接的任何位置添加以下代码即可。我们建议在循环之前添加它。
现在,如果您的主题有一个category.php 文件,只需在您希望显示订阅链接的位置添加以下代码即可。我们建议在循环之前添加它。
<?php
$category = get_category( get_query_var('cat') );
if ( ! empty( $category ) )
echo '<div class="category-feed"><p><a href="' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe to this category" rel="nofollow">Subscribe</a></p></div>';
?>
If your 才不是 have a category.php file, but it has an archive.php file, then create a new file called category.php and paste all the code from archive.php in it. Once you are done, then paste the above code in it.
如果您不 category.php文件,但是有archive.php文件,则创建一个名为category.php的新文件,然后将archive.php中的所有代码粘贴到其中。 完成后,将上面的代码粘贴到其中。
通过添加上述代码,您将能够在类别存档页面上看到订阅链接,如下所示:
添加以上代码后,您将可以在分类归档页面看到订阅链接,如下所示:

此代码只是将带有锚文本“订阅”的链接添加到模板。如果您愿意,可以通过添加 RSS 图标而不是文本来获得奇特效果。您所要做的就是用图像 URL 替换“订阅”文本,如下所示:
此代码仅将带有锚文本“订阅”的链接添加到模板。如果需要,您可以通过添加 RSS 图标而不是文本来获得奇特效果。您所要做的就是将“订阅”文本替换为图像 URL,如下所示:
<img src="http://example.com/location/to/rss/icon.png" width="48" height="48" alt="Subscribe" />
订阅图标示例如下所示:
订阅图标示例如下所示:

在WordPress中为类别添加其他订阅选项 (Adding Other Subscription Options for Categories in WordPress)
虽然大多数使用 RSS 阅读器的用户已经安装了浏览器扩展,但添加熟悉的图标来简化该过程总不会有什么坏处。举例来说,我们将为两个流行的基于 Web 的 RSS 阅读器应用程序(Feedly 和 Bloglines)添加按钮。如果您愿意,可以使用相同的技术添加其他服务。
尽管大多数 RSS 阅读器用户已经安装了浏览器扩展,但添加熟悉的图标来简化过程总没有坏处。例如,我们将为两个流行的基于 Web 的 RSS 阅读器应用程序 Feedly 和 Bloglines 添加按钮。如果您愿意,可以使用相同的技术添加其他服务。
Below is the sample code that you would need to add to your category.php
file:
以下是您需要添加到category.php
文件中的示例代码:
<?php
$category = get_category( get_query_var('cat') );
if ( ! empty( $category ) )
echo '<div class="category-feed"><p>Subcribe via: <a href="' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe to this category" rel="nofollow"><img src="http://example.com/location/to/rss/icon.png" width="32" height="32" alt="Subscribe" /></a>
<a href="http://www.feedly.com/home#subscription/feed/' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe via Feedly" rel="nofollow"><img src="http://example.com/location/to/feedly/icon.png" width="32" height="32" alt="Subscribe" /></a>
<a href="http://www.bloglines.com/sub/' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe via Bloglines" rel="nofollow"><img src="http://example.com/location/to/bloglines/icon.png" width="32" height="32" alt="Subscribe" /></a>
</p></div>';
?>
如您所见,我们修改了最后两个图标的类别提要链接。第一个图标仍然指向您的原始 RSS 提要,但第二个和第三个图标将用户带到 Feedly 和 Bloglines,以便他们可以订阅类别提要。这是它在我们的测试站点上的样子:
如您所见,我们修改了最后两个图标的类别提要链接。第一个图标仍然指向您的原始 RSS 提要,但第二个和第三个图标将用户带到 Feedly 和 Bloglines,以便他们可以订阅类别提要。这是它在我们的测试站点上的样子:

在WordPress中为类别添加电子邮件订阅 (Adding Email Subscription for Categories in WordPress)
When users look at our sidebar subscription option, they think each of those checkboxes are categories. While they are 不是 categories, the concept of adding category specific subscription is very similar.
当用户查看我们的侧边栏订阅选项时,他们认为每个复选框都是类别。 虽然它们不类别,但是添加特定于类别的订阅的概念非常相似。

To add email subscription for categories, you would need to utilize a third-party email subscription service like 邮件黑猩猩 or 阿韦伯. Both of these companies have a feature called RSS 到电子邮件. You would need to create a list segment aka groups, and then use those in combination with RSS to Email feature to accomplish email subscription for WordPress categories.
要为类别添加电子邮件订阅,您需要利用邮件黑猩猩或阿韦伯类的第三方电子邮件订阅服务。 这两家公司都具有称为RSS 到电子邮件的功能。 您将需要创建一个列表分段aka组,然后将其与RSS to Email功能结合使用以完成WordPress类别的电子邮件订阅。
We have created already written a guide on how to 创建每日和每周时事通讯 in WordPress which highlights all the same concepts. Please check that out to learn how to create groups and setup RSS to Email campaign.
我们已经创建了关于如何在WordPress中创建每日和每周通讯的指南 ,其中突出了所有相同的概念。 请检查一下,以了解如何创建组和设置RSS to Email活动。
The only difference is that you will have to create a RSS to Email campaign and Groups for each individual category. This is why it is very important that you are using 以正确的方式分类.
唯一的区别是,您将必须为每个单独的类别创建一个RSS to Email营销活动和组。 这就是为什么正确的使用类别非常重要的原因。
接下来,只需使用与上述代码相同的方法将表单代码复制并粘贴到类别页面上即可。
接下来,只需使用与上述代码相同的方法将表单代码复制并粘贴到类别页面上即可。
There is so much more you can do with your category RSS feeds. See our tutorial on 如何在 WordPress RSS 源中添加内容 and totally manipulate them.
您可以使用类别RSS feed进行更多操作。 请参阅我们的教程, 了解如何将内容添加到 WordPress RSS 源并对其进行完全操作。
我们希望本文能够帮助您为 WordPress 类别添加订阅选项。如果您有任何问题或建议,请在下面发表评论告诉我们。
我们希望本文能帮助您向 WordPress 类别添加订阅选项。如果您有任何问题或建议,请在下面发表评论告诉我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-allow-users-to-subscribe-to-categories-in-wordpress/
WordPress 电子邮件订阅