1. Trang chủ
  2. » Công Nghệ Thông Tin

Tìm Hiểu về Wordpress - part 20 potx

10 389 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

6.1.1 Working with RSS Feeds 6.1.2 Quick Introduction to Feeds One of the coolest things about using WordPress to power your site is the dynamic nature by which it organizes and generates content. Every post or article that you publish on your site is stored in a MySQL database on your server. WordPress then employs the PHP language to dynamically manipulate your database content to form individual posts, pages, and various types of feeds. Whereas a WordPress blog displays posts in sequential fashion on the home page and in various archive views, a WordPress feed displays posts in sequential fashion in specially formatted feeds. 6.1.3 Dynamic Publishing and Content Distribution In a nutshell, feeds enable subscribers to see in their feed readers the same content that is displayed on your blog. Each time you publish a new post, it appears simultaneously on your blog and in your WordPress feeds, which are formatted for use by third-party feed readers. This functionality has revolutionized the way content is delivered on the Web: instead of people having to visit your site to read your content, they can simply open their feed reader and read all of the latest articles from all of their favorite sites. The ease of this technology makes it easier to stay current with a much larger volume of information. Working with RSS Feeds 6 177 178 6.1.4 The Pros and Cons of Delivering RSS Feeds Just like with your actual website, anyone may visit and subscribe to your feed. This ease of access and convenience is a double-edge sword, however, especially for sites that depend on advertising revenue for sustainability and profit. Many people will not bother clicking through to your site if they are getting all of your content directly from your feed. Fortunately, there are some good ways to handle this situation, which we will explore later on in this chapter. With millions of blogs out there constantly generating new content, feeds enable users to stay current with a personalized collection of niche sites suited just for them. For site owners and content producers, however, there are a few considerable challenges associated with feeds: • Loss of site trafc, fewer click-throughs, visits, et al. • Loss of brand identity because of feed-reader uniformity • Stolen content due to unscrupulous spammers and scrapers Before addressing these various issues and some available solutions, let’s review some of the different types of feeds available for WordPress-powered sites. 6.2.1 Dierent Types of WordPress Feeds WordPress provides users with a wide variety of different feeds. There are feeds for just about every type of page-view, feeds for categories, feeds for tags, and even feeds that are customizable, including or excluding specific tags or categories. The possibilities are truly endless, especially when you consider that WordPress provides Don’t use relative links in your blog posts! Relative links look like this, “/path/to/le.html”, and may function properly from within your posts, but they will break when included in your feed. Because feeds are distributed on other domains, relative URLs for links and images will assume an incorrect base URL. If you are unable to avoid relative URLs on WordPress blogs, use a plugin such as URL Absolutifier http://digwp.com/u/84, which filters the feed content and converts any relative URLs to their absolute counterparts. 179 Choose Your Feed Reader! QUICK REVIEW OF SOME POPULAR FEED-READER CHOICES There are many feed readers available to choose from, including online services, mobile applications, and even desktop software. While all of these different readers do essentially the same thing – aggregate and display your favorite feeds – there are some key differences that you should consider. Let’s check out some of the more popular choices. Google Reader http://digwp.com/u/160 Millions of people use Google Reader. It is super-easy, fast, and provides many options, including the ability to “star” favorites, “like” posts, and even “share” feed items on your own website. Highly recommended. Bloglines http://digwp.com/u/162 Free and easy online feed aggregation service for searching, subscribing, creating, and sharing news feeds, blogs, and rich web content. Many features and fully customizable, including full support for mobile browsers and multiple languages. NewsGator http://digwp.com/u/163 Award-winning desktop-based RSS reader that comes in a variety of flavors: Windows, Mac, and iPhone. Thunderbird http://digwp.com/u/164 The powerful open-source email client is also an extremely powerful feed reader. Supports just about any feed format you can throw at it, and makes subscribing, managing, and reading feeds a real breeze. Firefox http://digwp.com/u/165 The world’s best browser makes it super-easy to stay current with all of your favorite sites. Using Firefox’s Live Bookmarks feature, you can automatically keep track of your feeds and know instantly when any of them are updated. Of course, this list is just the tip of the iceberg when it comes to feed readers. A quick search on your favorite search engine will provide many more great options. 180 many of these feeds in a multiple formats. Sounds overwhelming until you see the pattern of feeds and formats. Understanding the different types of WordPress feeds is important to running the best site possible. Let’s explore the different types of WordPress feeds. 6.2.2 Posts Feed Your site’s Post feed or main content feed is the primary source of content for subscribers. Unless specified otherwise with a plugin or custom script, each post that you create through the WordPress Admin will appear in your site’s Posts feed. Only post content appears in the main posts feed. It is available automatically here: http://domain.tld/feed/ Most sites serve their main content feed as their site’s primary feed. By default, it contains everything that is posted on your site, thereby making it easy for subscribers to stay current with all of your content. 6.2.3 Comments Feed Your site’s Comments feed includes a chronologically ordered display of all comments left on your site. Unless told to do otherwise, all author comments and all guest comments are included in the main comments feed. It is available automatically here: http://domain.tld/comments/feed/ Many sites also provide visitors with a link to subscribe to their comments feed. Typically, you will see links and/or icons for both the “main posts feed” and the “main comments feed” appearing next to one another. Providing these two feeds makes it easy for your readers to stay current with all of your content and all of your visitor’s comments. 181 6.2.4 Individual Post Comments Feed For each post on your site that enables people to leave comments, there is a corresponding feed that people may subscribe to in order to stay current with the conversation. Each Post Comment Feed includes all of the comments left on that particular post. Here is an example: http://domain.tld/2009/10/billy-mays-fan-club/feed/ When people leave comments on one of your posts, they can stay current with follow-up comments by subscribing to the Post-Comment Feed for that particular post. As useful as this method is, however, I think more people prefer to subscribe to comment updates via email. See the popout in 6.3.1 for more information. 6.2.5 Category and Tag Feeds In addition to the useful types of feeds discussed above, each individual Category and Tag archive on your site features its own feed. Each of these feeds includes all of the post content for its respective Category or Tag. Here is the general format for each type: http://domain.tld/category/football/feed/ http://domain.tld/tag/football/feed/ Category and tag feeds are extremely useful for providing topic-focused content to your subscribers. Sites that cover more than one particular niche may provide a feed for each particular topic, which may be more useful to readers than receiving news that is of no interest. Another good example for a category-specific feed is seen in the case of “Side Blogs,” “Asides,” “Mini Updates,” or whatever they’re called these days. Many bloggers keep a category set apart for posting brief thoughts, small snippets of news, links, and so on. A category-specific feed is perfect for enabling your subscribers to stay current with your “side” ramblings. 182 6.2.6 Other Feed Types There are also many other types of feeds that are automatically generated from your WordPress-powered site. There are feeds for each different author, chronological archives, and even pages. Many of these types of feeds are rarely seen in the wild, but they do exist and are available should you decide to use them. In addition to your post, comment, category, and tag feeds, WordPress provides several other types of feeds, including: • Author feed - http://domain.tld/author/blake/feed/ • Yearly archives - http://domain.tld/2009/feed/ • Monthly archives http://domain.tld/2009/10/feed/ • Daily archives - http://domain.tld/2009/10/30/feed/ • Page feed - http://domain.tld/about/feed/ In these generalized examples, you would replace “domain.tld” with your domain name, and then select an author name and/or specific date(s). List Category Feed Links with a Nice Feed Icon Here is a nice way to provide your visitors with a list of all your category feeds. Very useful if you have a lot of categories that have their own feeds. All we need is the wp_list_categories() tag and a few parameters: <?php wp_list_categories('feed_image=http://digwp.com/feed-icon.png&depth=1'); ?> This will output a nice list of all your parent-level categories along with a feed link icon next to each. Remember to use your own path for the feed image! For complete information on customizing this highly flexible tag, see the Codex http://digwp.com/u/86 Page Feeds Pages do create feeds, but unless you have comments enabled on that page, it usually doesn’t make sense to offer visitors a feed link for a page. 183 6.3.1 Feed Configurations and Formats Just as there are many different types of feeds, there are also many different types of feed formats. Each of the different feeds mentioned above is automatically generated in a variety of flavors: • RSS 2.0 Owned by Berkman Center, the RSS 2.0 format is extensible via modules and is recommended for general-purpose, metadata-rich syndication. • RSS 1.0 / RDF Owned by the RSS-DEV Working Group, the RSS 1.0 format is based on RDF, extensible via modules, and recommended for RDF-based applications. • RSS 0.92 Owned by UserLand, the RSS 0.92 format allows for richer metadata than its 0.91 predecessor. This version is now obsoleted by version 2.0. • Atom Created by leading service providers, tool vendors and independent developers, Atom is an XML-based document format designed to be a universal publishing standard for personal content and weblogs. Several years ago, choosing the best format to provide on your site was very important. Different feed readers accepted only certain formats, and the war was raging to see which format would finally win out. Fortunately, we no longer need to worry about which format to use because all of the most popular feed readers provide support for virtually all different feed formats. Many of the sites that we visit and interact with continue to deliver their feeds in RSS-2.0 format. The Atom Subscribe to Comments! Enable your visitors to stay current via email The easiest way to stay current with comment threads is to “subscribe to comments via email.” This functionality isn’t included with WordPress by default, but is easily added with Mark Jaquith’s excellent plugin, Subscribe to Comments http://digwp.com/u/85. Once installed, Subscribe to Comments provides a checkbox next to your comments that enables users to receive email notifications of any updates to that particular comment thread. Once subscribed, users will receive a simple plain-text email notifying them of the new comment, as well as links to manage their email subscriptions for that particular site. Unsubscribing at any time is as easy as clicking a few links. 184 format also has a loyal following, but is nowhere near as popular as the RSS 2.0 format. With all of these different formats, how does one distinguish between them? The answer is found in the URL structure of each particular type of feed. Here are a few examples of the general structure of the different feed formats for the Main Content Feed: • RSS 2.0 format - http://domain.tld/feed/ • RSS 2.0 format - http://domain.tld/feed/rss2/ • RSS 0.92 format - http://domain.tld/feed/rss/ • RDF/RSS 1.0 format - http://domain.tld/feed/rdf/ • Atom format - http://domain.tld/feed/atom/ This same basic pattern applies to all of the different types of WordPress feeds. Unless a particular format is appended to the end of the feed URL, the format is RSS 2.0. Otherwise, the format is determined by the particular “/format/” appended to the feed URL. For example, here are the various feed formats available for a hypothetical “Coffee” category: • http://domain.tld/category/coffee/feed/ • http://domain.tld/category/coffee/feed/rss2/ • http://domain.tld/category/coffee/feed/rss/ • http://domain.tld/category/coffee/feed/rdf/ • http://domain.tld/category/coffee/feed/atom/ And so on. Now that we are familiar with the myriad feed options provided by WordPress, let’s dig into the configuration and Feed URL Canonicalization Perhaps you’ve noticed that, for every feed on your site, there are two versions of the feed in the popular RSS 2.0 format. The first RSS-2.0 format is available when no specific format name is appended to the feed URL. The second RSS-2.0 format is available when the “/rss2/” format name is appended to the feed URL. To simplify this duplicity, you may want to “canonicalize” your RSS-2.0 feed. Canonicalization is the process of ensuring that each feed is available only at a specific URL. In general, canonicalization is good for SEO, statistics, and usability. Here is a quick HTAccess trick for ensuring that your RSS-2.0 feed is always delivered via the “http://domain.tld/feed/” URL: RedirectMatch 301 \/rss2\/ http:// domain.tld/feed/ Just add that rule to your site’s web- accessible root .htaccess file and test the results. Of course, there are many more canonicalization tricks at your disposal, and we cover some of them on page 306. 185 optimization of your site’s feeds. Once you have your site set up and a few posts published, the first thing you need to decide is whether to deliver “full feeds” or “partial feeds.” 6.3.2 Full Feeds Within the WordPress Admin (under Settings > Reading), there is an option to generate “full” feeds or “partial” feeds. By setting your feeds to deliver partial content, each post item in your feed is truncated according to either a specific number of characters, the presence of a post excerpt, or the location of the “read- more” (“<! more >”) tag. On the other hand, configuring your site to deliver full feeds basically means that you want your feed to include the entire content for each of the posts that you publish. While this certainly makes your feed more attractive to potential subscribers, it also invites greater opportunity for abuse. Many unscrupulous “scraper” sites on the Web make money by subscribing to full feeds, displaying them on their own sites, and placing advertisements next to them. Many other sites simply steal your content outright to pass off as their own work. Of course, there is another downside to providing full-content feeds. People are less likely to click through to your site to read the article when they can enjoy the entire thing in the comfort of their own feed reader. Fewer click-throughs means less traffic. Less traffic, in general, is not a good thing, especially if you need your visitors to translate into advertising revenue. Further, as they are not clicking through to your site, they are seeing less of your unique site design, logos, and other branding influence. Nonetheless, many people swear by the “full-feed” format. The reasoning behind this involves the argument that feeds are all about ease of distribution and open Truncated Feeds? Older versions of WordPress had a problem where feeds would be truncated at the <! more > tag even when the full feeds option was checked. If this is happening to you, 1) upgrade WordPress, or if you can’t, 2) use this plugin: http://digwp.com/u/87 Full Feeds Conguring full feeds is easy! Simply go to Settings > Reading in the Admin area, click on the Full-text option and save the changes. 186 sharing of content. As soon as you begin to restrict this core functionality, you detract from the benefits feeds provide while appearing manipulative and miserly. In other words, providing full feeds is generally seen as a very cool thing to do; while partial feeds on the other hand …not so much. 6.3.3 Partial Feeds While many people live and die by the full-feed method, there remain unavoidable issues involved with doing so. Fortunately, many, if not all, of the previously discussed difficulties are easily resolved by simply providing only partial feeds to your visitors. Partial feeds typically feature only the first few sentences of each post, or else display any explicitly defined excerpts included with each post. This format requires readers to actually click-through and visit your site if they decide the post is something they would like to read in its entirety. Thus, in visiting your site, traffic levels rise and advertising revenue may proportionally increase. Of course the other major benefit to only serving partial feeds is that scrapers and content thieves will have no real use for your content. They don’t waste time displaying partial feeds on their illicit sites, and the scrapers are generally too lazy to do anything that can’t be automated. The bottom line when it comes to displaying full versus partial feeds is that it all depends on your specific needs. If you are more concerned about ad revenue than being seen as someone who “gets it,” then partial feeds are most likely the way to go. Conversely, if your goal is to produce and share your content with as many like-minded subscribers as possible, then you don’t want to short-change them by providing anything less than the “full”-meal deal! Partial Feeds Conguring partial feeds is just as easy. Simply go to Settings > Reading in the Admin area, click on the Summary option and save the changes. . on that particular post. Here is an example: http://domain.tld /200 9/10/billy-mays-fan-club/feed/ When people leave comments on one of your posts, they can stay current with follow-up comments. available for WordPress- powered sites. 6.2.1 Dierent Types of WordPress Feeds WordPress provides users with a wide variety of different feeds. There are feeds for just about every type of page-view,. with as many like-minded subscribers as possible, then you don’t want to short-change them by providing anything less than the “full”-meal deal! Partial Feeds Conguring partial feeds is just

Ngày đăng: 04/07/2014, 21:20

w