
wordpress邮箱订阅
WordPress comes with built-in taxonomies, categories and tags, 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 (What is 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 custom taxonomy. 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/
Now the easiest way to allow users to subscribe to categories in WordPress is by letting them know about it. You can add a category RSS feed link on each category page. You can also also add other subscription options such as feedly, and bloglines. Last but certainly not the least, you can allow them to subscribe to category via email. Let’s look at all of these options in details.
现在,允许用户订阅WordPress中的类别的最简单方法是让他们知道。 您可以在每个类别页面上添加类别RSS feed链接。 您还可以添加其他订阅选项,例如feedly和bloglines。 最后但并非最不重要的一点是,您可以允许他们通过电子邮件订阅类别。 让我们详细了解所有这些选项。
在类别页面上添加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 theme framework, and this article will not be as helpful for you.
让我们从在类别页面上添加简单的RSS订阅链接开始。 您需要做的第一件事是进入主题文件夹,然后找到文件category.php
。 如果没有看到category.php,请寻找archive.php
。 如果您没有看到任何一个,则很有可能您正在使用WordPress主题框架 ,并且本文对您没有帮助。
Now if your theme has a category.php file, then simply add the following code wherever you want to display the subscription link. We would recommend adding it right before the loop.
现在,如果您的主题有一个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 does not 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中的所有代码粘贴到其中。 完成后,将上面的代码粘贴到其中。
By adding the above code, you will be able to see a subscribe link on your category archive page like so:
通过添加以上代码,您将可以在类别存档页面上看到订阅链接,如下所示:

This code simply adds a link with the anchor text ‘Subscribe’ to the template. You can get fancy by adding an RSS icon instead of text if you prefer. All you have to do is replace the “Subscribe” text with an image URL like so:
此代码仅将带有锚文本“ Subscribe”的链接添加到模板。 如果您愿意,可以通过添加RSS图标而不是文本来获得幻想。 您所要做的就是用图像URL替换“ Subscribe”文本,如下所示:
<img src="http://example.com/location/to/rss/icon.png" width="48" height="48" alt="Subscribe" />
An example subscription icon would look like this:
订阅图标示例如下所示:

在WordPress中为类别添加其他订阅选项 (Adding Other Subscription Options for Categories in WordPress)
While most users who use a RSS reader already have the browser extension installed, but it can never hurt to add familiar icons to ease the process. For the sake of example, we will add buttons for two popular web based RSS reader apps, Feedly and Bloglines. You can use the same technique to add other services if you like.
尽管大多数使用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>';
?>
As you can see, we have modified the category feed links for the last two icons. The first icon still points to your original RSS feed, but the second and third icon takes the users to Feedly and Bloglines, so they can subscribe to the category feed. This is how it looked on our test site:
如您所见,我们修改了最后两个图标的类别供稿链接。 第一个图标仍然指向您的原始RSS feed,但是第二个和第三个图标将用户带到Feedly和Bloglines,因此他们可以订阅类别feed。 这是在我们的测试站点上的外观:

在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 not 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 MailChimp or Aweber. Both of these companies have a feature called RSS to Email. 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.
要为类别添加电子邮件订阅,您需要利用MailChimp或Aweber之类的第三方电子邮件订阅服务。 这两家公司都具有称为RSS to Email的功能。 您将需要创建一个列表分段aka组,然后将其与RSS to Email功能结合使用以完成WordPress类别的电子邮件订阅。
We have created already written a guide on how to create a daily and weekly newsletter 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 categories the right way.
唯一的区别是,您将必须为每个单独的类别创建一个RSS to Email营销活动和组。 这就是为什么正确使用类别非常重要的原因。
Next, simply copy and paste your form code on your category pages using the same method as the codes above.
接下来,只需使用与上述代码相同的方法,将表单代码复制并粘贴到类别页面上即可。
There is so much more you can do with your category RSS feeds. See our tutorial on how to add content in your WordPress RSS feeds and totally manipulate them.
您可以使用类别RSS feed进行更多操作。 请参阅我们的教程, 了解如何在WordPress RSS feed中添加内容并对其进行完全操作。
We hope that this article helped you in adding subscription options for your WordPress categories. If you have any questions or suggestions, then please let us know by leaving a comment below.
我们希望本文能帮助您为WordPress类别添加订阅选项。 如果您有任何疑问或建议,请在下面留下评论,让我们知道。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-allow-users-to-subscribe-to-categories-in-wordpress/
wordpress邮箱订阅