June 11, 2013 @ 02:16:30 [Autosave] | Current Revision |
Content |
Unchanged: Resources taken from here: D<a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #customize-examples" target="_blank">igging into WordPress</a> | Unchanged: Resources taken from here: D<a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #customize-examples" target="_blank">igging into WordPress</a> |
Unchanged: WordPress feeds enable your visitors to subscribe to your content for use in their favorite feed-reader. For example, subscribing to the main-posts feed and/or the comments feed is a great way for your readers to stay current with all the latest from your site. | Unchanged: WordPress feeds enable your visitors to subscribe to your content for use in their favorite feed-reader. For example, subscribing to the main-posts feed and/or the comments feed is a great way for your readers to stay current with all the latest from your site. |
| Added: |
Unchanged: With WordPress, you can deliver a wide variety of “Full-text” or “Summary” (partial) feeds in numerous formats, including Atom, <abbr title="Resource Description Framework">RDF</abbr>, and <abbr title="Really Simple Syndication 2.0">RSS2</abbr>. This variety extends the reach of your content by enabling your feeds to be read in more apps, readers, and devices. | Unchanged: With WordPress, you can deliver a wide variety of “Full-text” or “Summary” (partial) feeds in numerous formats, including Atom, <abbr title="Resource Description Framework">RDF</abbr>, and <abbr title="Really Simple Syndication 2.0">RSS2</abbr>. This variety extends the reach of your content by enabling your feeds to be read in more apps, readers, and devices. |
Unchanged: As awesome as the default feeds may be, they are also readily customizable using a variety of methods. In addition to <abbr title="WordPress" >WP</abbr>‘s built-in ways of configuring your feeds, you can go even further with custom templates, functions, and plugins. In this <abbr title="Digging into WordPress">DigWP< /abbr> post, you’ll learn everything you need to customize your feeds with bonus content, recent posts, social media, and much more. | Unchanged: As awesome as the default feeds may be, they are also readily customizable using a variety of methods. In addition to <abbr title="WordPress" >WP</abbr>‘s built-in ways of configuring your feeds, you can go even further with custom templates, functions, and plugins. In this <abbr title="Digging into WordPress">DigWP< /abbr> post, you’ll learn everything you need to customize your feeds with bonus content, recent posts, social media, and much more. |
Unchanged: <h4>Contents</h4> | Unchanged: <h4>Contents</h4> |
Unchanged: <ul id="wordpress- feeds-menu"> | Unchanged: <ul id="wordpress- feeds-menu"> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#overview" >Overview</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#overview" >Overview</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #feed-template-files">Feed Template Files</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #feed-template-files">Feed Template Files</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- wordpress">Built-in ways to customize feeds</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- wordpress">Built-in ways to customize feeds</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- templates">Customize with custom templates</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- templates">Customize with custom templates</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- plugins">Customizing with WP plugns</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- plugins">Customizing with WP plugns</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- filters-hooks" >Customizing feeds with filters and hooks</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- filters-hooks" >Customizing feeds with filters and hooks</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- examples">Examples of customizing feeds via functions.php</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/#customize- examples">Examples of customizing feeds via functions.php</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #conclusion" >Conclusion</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #conclusion" >Conclusion</a></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: <h3 id="overview">Overview of WordPress feeds</h3> | Unchanged: <h3 id="overview">Overview of WordPress feeds</h3> |
Unchanged: By default WordPress generates a feed for just about everything, as seen in this overview: | Unchanged: By default WordPress generates a feed for just about everything, as seen in this overview: |
Unchanged: <table id="wordpress-feeds"> | Unchanged: <table id="wordpress-feeds"> |
Unchanged: <thead> | Unchanged: <thead> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <th>Feed type</th> | Unchanged: <th>Feed type</th> |
Unchanged: <th>Description</th> | Unchanged: <th>Description</th> |
Unchanged: <th>Example*</th> | Unchanged: <th>Example*</th> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: </thead> | Unchanged: </thead> |
Unchanged: <tbody> | Unchanged: <tbody> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>All Posts</td> | Unchanged: <td>All Posts</td> |
Unchanged: <td>Main content feed – includes your latest posts</td> | Unchanged: <td>Main content feed – includes your latest posts</td> |
Unchanged: <td><a href="http:// digwp.com/feed/ ">http://digwp.com/ feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/feed/ ">http://digwp.com/ feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>All Comments</td> | Unchanged: <td>All Comments</td> |
Unchanged: <td>Main comments feed – includes latest comments</td> | Unchanged: <td>Main comments feed – includes latest comments</td> |
Unchanged: <td><a href="http:// digwp.com/comments/feed/" >http://digwp.com/comments/ feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/comments/feed/" >http://digwp.com/comments/ feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>Individual Posts</td> | Unchanged: <td>Individual Posts</td> |
Unchanged: <td>Includes latest comments on a specific post</td> | Unchanged: <td>Includes latest comments on a specific post</td> |
Unchanged: <td><a href="http:// digwp.com/2009/07/getting- more-fine-grained- with-includes/ feed/">http:/ /digwp.com/2009/ 07/getting-more- fine-grained- with-includes/ feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/2009/07/getting- more-fine-grained- with-includes/ feed/">http:/ /digwp.com/2009/ 07/getting-more- fine-grained- with-includes/ feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>Individual Pages</td> | Unchanged: <td>Individual Pages</td> |
Unchanged: <td>Includes latest comments on a specific page</td> | Unchanged: <td>Includes latest comments on a specific page</td> |
Unchanged: <td><a href="http:// digwp.com/archives/feed/" >http://digwp.com/archives/ feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/archives/feed/" >http://digwp.com/archives/ feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>Archives</td> | Unchanged: <td>Archives</td> |
Unchanged: <td>Day, month, year – includes latest posts in each archive</td> | Unchanged: <td>Day, month, year – includes latest posts in each archive</td> |
Unchanged: <td><a href="http:// digwp.com/2010/ feed/">http: //digwp.com/2010/ feed/</a>,<a href="http:// digwp.com/2010/10/feed/"> http://digwp.com/2010/10/ feed/</a>,<a href="http:// digwp.com/2010/10/02/feed/ ">http://digwp.com/2010/10/ 02/feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/2010/ feed/">http: //digwp.com/2010/ feed/</a>,<a href="http:// digwp.com/2010/10/feed/"> http://digwp.com/2010/10/ feed/</a>,<a href="http:// digwp.com/2010/10/02/feed/ ">http://digwp.com/2010/10/ 02/feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: <tr> | Unchanged: <tr> |
Unchanged: <td>Search Results</td> | Unchanged: <td>Search Results</td> |
Unchanged: <td>Includes latest posts for a particular search query</td> | Unchanged: <td>Includes latest posts for a particular search query</td> |
Unchanged: <td><a href="http:// digwp.com/search/term/feed/ ">http://digwp.com/search/ term/feed/</a></td> | Unchanged: <td><a href="http:// digwp.com/search/term/feed/ ">http://digwp.com/search/ term/feed/</a></td> |
Unchanged: </tr> | Unchanged: </tr> |
Unchanged: </tbody> | Unchanged: </tbody> |
Unchanged: </table> | Unchanged: </table> |
Unchanged: * <em>Note: examples show feed URLs when <a title="WP Codex: Using Permalinks" href="http:// codex.wordpress.org/Using_ Permalinks">WP permalinks</a> are enabled.</em> | Unchanged: * <em>Note: examples show feed URLs when <a title="WP Codex: Using Permalinks" href="http:// codex.wordpress.org/Using_ Permalinks">WP permalinks</a> are enabled.</em> |
Unchanged: As if that many feeds weren’t enough, each type of feed is available is the following formats: | Unchanged: As if that many feeds weren’t enough, each type of feed is available is the following formats: |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><strong>Atom< /strong> – append <code> /atom/</code> to any type of feed</li> | Unchanged: <li><strong>Atom< /strong> – append <code> /atom/</code> to any type of feed</li> |
Unchanged: <li><strong>RDF< /strong> – append <code> /rdf/</code> to any type of feed</li> | Unchanged: <li><strong>RDF< /strong> – append <code> /rdf/</code> to any type of feed</li> |
Unchanged: <li><strong>RSS2< /strong> – append <code> /feed/</code> , <code>/feed/ rss/</code>, or <code>/feed/ rss2/</code> to just about any WP-generated page (this is the default feed format)</li> | Unchanged: <li><strong>RSS2< /strong> – append <code> /feed/</code> , <code>/feed/ rss/</code>, or <code>/feed/ rss2/</code> to just about any WP-generated page (this is the default feed format)</li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: For more details, here’s a complete guide to all of the different <a title="What is My WordPress Feed URL?" href="http:// perishablepress.com/what- is-my-wordpress- feed-url/">WordPress feed URLs</a>. | Unchanged: For more details, here’s a complete guide to all of the different <a title="What is My WordPress Feed URL?" href="http:// perishablepress.com/what- is-my-wordpress- feed-url/">WordPress feed URLs</a>. |
Unchanged: <strong>Note: </strong> In previous versions of WordPress feeds were also generated in <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 format, but those now are redirected to their respective <abbr title="Really Simple Syndication"> RSS</abbr>-2.0 formats, even though the template file for RSS-0.92 still exists in the core. The feed template files are what WordPress uses to generate the various types of feeds in their various formats. Let’s take a look.. | Unchanged: <strong>Note: </strong> In previous versions of WordPress feeds were also generated in <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 format, but those now are redirected to their respective <abbr title="Really Simple Syndication"> RSS</abbr>-2.0 formats, even though the template file for RSS-0.92 still exists in the core. The feed template files are what WordPress uses to generate the various types of feeds in their various formats. Let’s take a look.. |
Unchanged: <h3 id="feed-template-files">Feed Template files</h3> | Unchanged: <h3 id="feed-template-files">Feed Template files</h3> |
Unchanged: To generate the different feed formats — Atom, RDF, and RSS2 — for its myriad feed types, WordPress employs the following template files: | Unchanged: To generate the different feed formats — Atom, RDF, and RSS2 — for its myriad feed types, WordPress employs the following template files: |
Unchanged: <strong>Post-based feeds</strong> | Unchanged: <strong>Post-based feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>/wp- includes/feed- atom.php</code></li> | Unchanged: <li><code>/wp- includes/feed- atom.php</code></li> |
Unchanged: <li><code>/wp- includes/feed- rdf.php</code></li> | Unchanged: <li><code>/wp- includes/feed- rdf.php</code></li> |
Unchanged: <li><code>/wp- includes/feed- rss.php</code></li> | Unchanged: <li><code>/wp- includes/feed- rss.php</code></li> |
Unchanged: <li><code>/wp- includes/feed- rss2.php</code></li> | Unchanged: <li><code>/wp- includes/feed- rss2.php</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: The post-based feeds look self-explanatory: <code>feed- atom.php</code> is used for Atom feeds, <code> feed-rdf.php< /code> for <abbr title="Resource Description Framework">RDF< /abbr> feeds, and so on. As mentioned, the thing to note here is that the <code>feed- rss.php</code>(for the <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 format) still exists in the WP core, even though it’s no longer used, <abbr title="as far as I know">afaik</abbr>. | Unchanged: The post-based feeds look self-explanatory: <code>feed- atom.php</code> is used for Atom feeds, <code> feed-rdf.php< /code> for <abbr title="Resource Description Framework">RDF< /abbr> feeds, and so on. As mentioned, the thing to note here is that the <code>feed- rss.php</code>(for the <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 format) still exists in the WP core, even though it’s no longer used, <abbr title="as far as I know">afaik</abbr>. |
Unchanged: <strong>Comment-based feeds</strong> | Unchanged: <strong>Comment-based feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>/wp- includes/feed- atom-comments.php</code></li> | Unchanged: <li><code>/wp- includes/feed- atom-comments.php</code></li> |
Unchanged: <li><code>/wp- includes/feed- rss2-comments.php</code></li> | Unchanged: <li><code>/wp- includes/feed- rss2-comments.php</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: The comment-based feeds are available in only two flavors: Atom and <abbr title="Really Simple Syndication"> RSS</abbr> 2.0. As with post feeds, requests for <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 comment feeds are redirected to their respective RSS-2.0 formats. Also worth noting, requests for <abbr title="Resource Description Framework">RDF< /abbr>-formatted comment feeds are mysteriously redirected to RSS2 <em>post< /em> feeds. Examples: | Unchanged: The comment-based feeds are available in only two flavors: Atom and <abbr title="Really Simple Syndication"> RSS</abbr> 2.0. As with post feeds, requests for <abbr title="Really Simple Syndication"> RSS</abbr>-0.92 comment feeds are redirected to their respective RSS-2.0 formats. Also worth noting, requests for <abbr title="Resource Description Framework">RDF< /abbr>-formatted comment feeds are mysteriously redirected to RSS2 <em>post< /em> feeds. Examples: |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><a href="http:// digwp.com/comments/feed/rdf/ ">http://digwp.com/comments/ feed/rdf/</a></li> | Unchanged: <li><a href="http:// digwp.com/comments/feed/rdf/ ">http://digwp.com/comments/ feed/rdf/</a></li> |
Unchanged: <li><a href="http:// digwp.com/2012/ 09/notification- list-for-new- books/feed/rdf/ ">http://digwp.com/2012/09/ notification- list-for-new- books/feed/rdf/</a></li> | Unchanged: <li><a href="http:// digwp.com/2012/ 09/notification- list-for-new- books/feed/rdf/ ">http://digwp.com/2012/09/ notification- list-for-new- books/feed/rdf/</a></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: For each of these examples, it would make more sense to redirect to the respective RSS2-formatted < em>comments</em> feed, rather than to any of the post feeds. | Unchanged: For each of these examples, it would make more sense to redirect to the respective RSS2-formatted < em>comments</em> feed, rather than to any of the post feeds. |
Unchanged: <strong>Feed functions</strong> | Unchanged: <strong>Feed functions</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>/wp- includes/feed.php</code></li> | Unchanged: <li><code>/wp- includes/feed.php</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: Lastly, the <code>feed.php< /code> file contains some of the key functions used in the various feed-templates. For example, the <code>rss_ enclosure()</ code> function is used in <code>feed- rss2.php</code> to display any <a title="RSS enclosure Element" href="http:// www.w3schools.com/rss/rss_ tag_enclosure.asp">RSS enclosure(s)< /a> included for the current post. So, if you’ve added, say, the following enclosure to your latest post (via custom field named “<code>enclosure</code>”): | Unchanged: Lastly, the <code>feed.php< /code> file contains some of the key functions used in the various feed-templates. For example, the <code>rss_ enclosure()</ code> function is used in <code>feed- rss2.php</code> to display any <a title="RSS enclosure Element" href="http:// www.w3schools.com/rss/rss_ tag_enclosure.asp">RSS enclosure(s)< /a> included for the current post. So, if you’ve added, say, the following enclosure to your latest post (via custom field named “<code>enclosure</code>”): |
Unchanged: <code><enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /></code> | Unchanged: <code><enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /></code> |
Unchanged: WordPress will automatically insert the enclosure into your RSS2 feed via the <code>rss_ enclosure()</ code>function. Here is what your feed’s <abbr title="eXtensible Markup Language">XML< /abbr> will look like after the enclosure is included (line breaks added for emphasis): | Unchanged: WordPress will automatically insert the enclosure into your RSS2 feed via the <code>rss_ enclosure()</ code>function. Here is what your feed’s <abbr title="eXtensible Markup Language">XML< /abbr> will look like after the enclosure is included (line breaks added for emphasis): |
Unchanged: <pre><code><item> | Unchanged: <pre><code><item> |
Unchanged: <title>Awesome Video</title> | Unchanged: <title>Awesome Video</title> |
Unchanged: <link>http: //example.com/ awesome-video/ </link> | Unchanged: <link>http: //example.com/ awesome-video/ </link> |
Unchanged: <comments> http://example.com/awesome- video/#comments< /comments> | Unchanged: <comments> http://example.com/awesome- video/#comments< /comments> |
Unchanged: <pubDate>Wed, 17 Oct 2012 06:51:07 +0000</pubDate> | Unchanged: <pubDate>Wed, 17 Oct 2012 06:51:07 +0000</pubDate> |
Unchanged: <dc:creator> Perishable< /dc:creator> | Unchanged: <dc:creator> Perishable< /dc:creator> |
Unchanged: <category> <![CDATA[WordPress]]> </category> | Unchanged: <category> <![CDATA[WordPress]]> </category> |
Unchanged: <guid isPermaLink=" false">http: //example.com/ ?p=132</guid> | Unchanged: <guid isPermaLink=" false">http: //example.com/ ?p=132</guid> |
Unchanged: <description> <![CDATA[Check out this awesome video..]]> </description> | Unchanged: <description> <![CDATA[Check out this awesome video..]]> </description> |
Unchanged: <wfw:commentRss> http://example.com/awesome- video/feed/< /wfw:commentRss> | Unchanged: <wfw:commentRss> http://example.com/awesome- video/feed/< /wfw:commentRss> |
Unchanged: <slash:comments> 500</slash: comments> | Unchanged: <slash:comments> 500</slash: comments> |
Unchanged: <enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /> | Unchanged: <enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /> |
Unchanged: </item> </code></pre> | Unchanged: </item> </code></pre> |
Unchanged: And here’s what we see near the end of the <code>feed- rss2.php</code> template that makes it happen: | Unchanged: And here’s what we see near the end of the <code>feed- rss2.php</code> template that makes it happen: |
Unchanged: <pre><code>. | Unchanged: <pre><code>. |
Unchanged: . | Unchanged: . |
Unchanged: . | Unchanged: . |
Unchanged: <wfw:commentRss><?php echo esc_url( get_post_comments_ feed_link(null, 'rss2') ); ?></wfw: commentRss> | Unchanged: <wfw:commentRss><?php echo esc_url( get_post_comments_ feed_link(null, 'rss2') ); ?></wfw: commentRss> |
Unchanged: <slash:comments><?php echo get_comments_number(); ?></slash: comments> | Unchanged: <slash:comments><?php echo get_comments_number(); ?></slash: comments> |
Unchanged: <?php rss_enclosure(); ?> | Unchanged: <?php rss_enclosure(); ?> |
Unchanged: <?php do_action('rss2_item'); ?> | Unchanged: <?php do_action('rss2_item'); ?> |
Unchanged: </item> | Unchanged: </item> |
Unchanged: <?php endwhile; ?> | Unchanged: <?php endwhile; ?> |
Unchanged: </channel> | Unchanged: </channel> |
Unchanged: </rss>< /code></pre> | Unchanged: </rss>< /code></pre> |
Unchanged: There is a similar function for including enclosures for Atom feeds, <code> atom_enclosure</code>, which is also included in <code>feed.php</code>. And so, now that we’re all up to speed on the what, why and where, let’s apply the information as we learn how to customize our own WordPress feeds. | Unchanged: There is a similar function for including enclosures for Atom feeds, <code> atom_enclosure</code>, which is also included in <code>feed.php</code>. And so, now that we’re all up to speed on the what, why and where, let’s apply the information as we learn how to customize our own WordPress feeds. |
Unchanged: <h3 id="customize- wordpress">Built-in ways to customize feeds</h3> | Unchanged: <h3 id="customize- wordpress">Built-in ways to customize feeds</h3> |
Unchanged: The <em>easiest</em> way to customize your feeds is by using the built-in options that WordPress provides. Probably these are familiar to most of us, but they’re worth mentioning along with some of their pros and cons: | Unchanged: The <em>easiest</em> way to customize your feeds is by using the built-in options that WordPress provides. Probably these are familiar to most of us, but they’re worth mentioning along with some of their pros and cons: |
Unchanged: <strong>Full-text or Summary feed?</strong> | Unchanged: <strong>Full-text or Summary feed?</strong> |
Unchanged: If you visit “Settings” > “Reading Settings”, you can choose whether to syndicate your complete posts or only the excerpt. Note: does not apply to comment feeds, which always display comments in their entirety. Delivering partial-feeds is a good way to prevent content-scraping, while delivering full-feeds makes it easier for your readers to stay current (i.e., they don’t have to visit your site, which may be another reason to use partial feeds). | Unchanged: If you visit “Settings” > “Reading Settings”, you can choose whether to syndicate your complete posts or only the excerpt. Note: does not apply to comment feeds, which always display comments in their entirety. Delivering partial-feeds is a good way to prevent content-scraping, while delivering full-feeds makes it easier for your readers to stay current (i.e., they don’t have to visit your site, which may be another reason to use partial feeds). |
Unchanged: <strong>Number of posts/comments to include in feeds</strong> | Unchanged: <strong>Number of posts/comments to include in feeds</strong> |
Unchanged: To customize the number of items that appear in your post and comment feeds, visit “Settings” > “Reading Settings” and adjust the option, “Syndication feeds show the most recent”. The number that you choose will apply to both post and comment feeds. | Unchanged: To customize the number of items that appear in your post and comment feeds, visit “Settings” > “Reading Settings” and adjust the option, “Syndication feeds show the most recent”. The number that you choose will apply to both post and comment feeds. |
Unchanged: Including larger numbers of posts can make your feed look more attractive to potential subscribers, which may be useful when delivering partial feeds. When delivering full-feeds, however, you may be better served by choosing a lower number of feed items. Here at<a href="http:// digwp.com/">DigWP.com</a>, we deliver full-text feeds, eight at a time. | Unchanged: Including larger numbers of posts can make your feed look more attractive to potential subscribers, which may be useful when delivering partial feeds. When delivering full-feeds, however, you may be better served by choosing a lower number of feed items. Here at<a href="http:// digwp.com/">DigWP.com</a>, we deliver full-text feeds, eight at a time. |
Unchanged: <strong>Character encoding for feeds</strong> | Unchanged: <strong>Character encoding for feeds</strong> |
Unchanged: While the default <abbr title="Unicode Transformation Format (8-bit)">UTF- 8</abbr> character-encoding is recommended, it is possible to choose an alternate encoding method. Visit “Settings” > “Reading Settings” > “Encoding for pages and feeds” to make it happen. | Unchanged: While the default <abbr title="Unicode Transformation Format (8-bit)">UTF- 8</abbr> character-encoding is recommended, it is possible to choose an alternate encoding method. Visit “Settings” > “Reading Settings” > “Encoding for pages and feeds” to make it happen. |
Unchanged: <h3 id="customize- templates">Customize with custom templates</h3> | Unchanged: <h3 id="customize- templates">Customize with custom templates</h3> |
Unchanged: As explained in <a title="Easy Custom Feeds in WordPress" href="http:// digwp.com/2009/ 09/easy-custom- feeds-in-wordpress/ ">previous</a> <a title="Create an Articles-Only Feed" href="http:// digwp.com/2011/08/custom- feeds/">posts</a>, a great way to generate custom feeds is to use a custom feed template. Those posts explain it all in detail, with the basic idea going something like this: | Unchanged: As explained in <a title="Easy Custom Feeds in WordPress" href="http:// digwp.com/2009/ 09/easy-custom- feeds-in-wordpress/ ">previous</a> <a title="Create an Articles-Only Feed" href="http:// digwp.com/2011/08/custom- feeds/">posts</a>, a great way to generate custom feeds is to use a custom feed template. Those posts explain it all in detail, with the basic idea going something like this: |
Unchanged: <ol> | Unchanged: <ol> |
Unchanged: <li><strong>Create a custom page template</strong> – and paste into it any existing feed template</li> | Unchanged: <li><strong>Create a custom page template</strong> – and paste into it any existing feed template</li> |
Unchanged: <li><strong>Modify the custom feed template</strong> – for example, change the number of posts, make it a category-specific feed, add custom XML enclosures, and so on.</li> | Unchanged: <li><strong>Modify the custom feed template</strong> – for example, change the number of posts, make it a category-specific feed, add custom XML enclosures, and so on.</li> |
Unchanged: <li><strong>Provide a link to the feed</strong> – once everything is in place, the custom feed will be available at the URL of its custom page.</li> | Unchanged: <li><strong>Provide a link to the feed</strong> – once everything is in place, the custom feed will be available at the URL of its custom page.</li> |
Unchanged: </ol> | Unchanged: </ol> |
Unchanged: As you can imagine, using custom feed templates is an ideal approach, but it’s also possible to modify your <em>existing</em> feeds (instead of creating new ones). Read on to learn how.. | Unchanged: As you can imagine, using custom feed templates is an ideal approach, but it’s also possible to modify your <em>existing</em> feeds (instead of creating new ones). Read on to learn how.. |
Unchanged: <h3 id="customize- plugins">Customizing with WP plugns</h3> | Unchanged: <h3 id="customize- plugins">Customizing with WP plugns</h3> |
Unchanged: The easiest way to go further than default WP customization options is to use a plugin. There are many available. Here are some of our favorites that show the wide range of feed-customizing that’s possible with <em>free< /em> WordPress plugins: | Unchanged: The easiest way to go further than default WP customization options is to use a plugin. There are many available. Here are some of our favorites that show the wide range of feed-customizing that’s possible with <em>free< /em> WordPress plugins: |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ comments-on-feed/">Comments On Feed</a> – enables visitors to view and leave comments directly from each post in the WordPress content feed.</li> | Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ comments-on-feed/">Comments On Feed</a> – enables visitors to view and leave comments directly from each post in the WordPress content feed.</li> |
Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ feed-template- customize/">Feed Template Customize</a> – enables you to modify WP’s RSS and Atom feeds using your own custom feed-templates.</li> | Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ feed-template- customize/">Feed Template Customize</a> – enables you to modify WP’s RSS and Atom feeds using your own custom feed-templates.</li> |
Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ rss-image-feed/">RSS Image Feed</a> – adds the first image of a post to your feeds, even in Firefox and even if you only display the excerpt.</li> | Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ rss-image-feed/">RSS Image Feed</a> – adds the first image of a post to your feeds, even in Firefox and even if you only display the excerpt.</li> |
Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ rss-custom-fields/">RSS Custom Fields</a> – includes all of your custom fields in your feed so you can pull data out of WordPress and use it elsewhere.</li> | Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ rss-custom-fields/">RSS Custom Fields</a> – includes all of your custom fields in your feed so you can pull data out of WordPress and use it elsewhere.</li> |
Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ custom-post-type- rss-feed/">Custom Post Type RSS feeds</a> – makes it “super easy” to create an RSS feed based on custom post types.</li> | Unchanged: <li><a href="http:// wordpress.org/ extend/plugins/ custom-post-type- rss-feed/">Custom Post Type RSS feeds</a> – makes it “super easy” to create an RSS feed based on custom post types.</li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: And there’s many more feed-tweaking plugins available in the <a href="http:// wordpress.org/ extend/plugins/">WordPress Plugin Directory</a>and <a href="http:// google.com/"> elsewhere</a>. Knock yourself out 🙂 | Unchanged: And there’s many more feed-tweaking plugins available in the <a href="http:// wordpress.org/ extend/plugins/">WordPress Plugin Directory</a>and <a href="http:// google.com/"> elsewhere</a>. Knock yourself out 🙂 |
Unchanged: <h3 id="customize- filters-hooks" >Customizing feeds with filters and hooks</h3> | Unchanged: <h3 id="customize- filters-hooks" >Customizing feeds with filters and hooks</h3> |
Unchanged: The most <em>direct</em> way of customizing WordPress feeds is to <a title="Precision Targeting with Custom Action Hooks" href="http:// digwp.com/2009/ 09/wordpress- action-hooks/">hook into them directly</a> with<a title="WP Codex: Plugin API/Action Reference" href="http:// codex.wordpress.org/Plugin_ API/Action_Reference">actions< /a> and <a title="WP Codex: Plugin API/Filter Reference" href="http:// codex.wordpress.org/Plugin_ API/Filter_Reference" >filters</a>. For example, WP hooks make it easy to add custom content: | Unchanged: The most <em>direct</em> way of customizing WordPress feeds is to <a title="Precision Targeting with Custom Action Hooks" href="http:// digwp.com/2009/ 09/wordpress- action-hooks/">hook into them directly</a> with<a title="WP Codex: Plugin API/Action Reference" href="http:// codex.wordpress.org/Plugin_ API/Action_Reference">actions< /a> and <a title="WP Codex: Plugin API/Filter Reference" href="http:// codex.wordpress.org/Plugin_ API/Filter_Reference" >filters</a>. For example, WP hooks make it easy to add custom content: |
Unchanged: <pre><code>// add custom feed content | Unchanged: <pre><code>// add custom feed content |
Unchanged: function add_feed_content($content) { | Unchanged: function add_feed_content($content) { |
Unchanged: if(is_feed()) { | Unchanged: if(is_feed()) { |
Unchanged: $content .= '<p>This article is copyright &copy; '.date('Y').'& nbsp;'.bloginfo( 'name').'</p>'; | Unchanged: $content .= '<p>This article is copyright &copy; '.date('Y').'& nbsp;'.bloginfo( 'name').'</p>'; |
Unchanged: } | Unchanged: } |
Unchanged: return $content; | Unchanged: return $content; |
Unchanged: } | Unchanged: } |
Unchanged: add_filter('the_ excerpt_rss', 'add_feed_content'); | Unchanged: add_filter('the_ excerpt_rss', 'add_feed_content'); |
Unchanged: add_filter('the_content', 'add_feed_content') ;</code></pre> | Unchanged: add_filter('the_content', 'add_feed_content') ;</code></pre> |
Unchanged: With that snippet included in your theme’s <a title="WordPress functions.php Template with 15 Essential Custom Functions" href="http:// digwp.com/2010/ 03/wordpress- functions-php- template-custom- functions/">functions.php</a> file, WordPress will display a line of copyright information (for example) to each of your feed items. Of course, much more is possible once you’re able to target hooks for <em>specific< /em> feeds. Fortunately, WordPress provides some useful <em>format- specific</em> feed hooks: | Unchanged: With that snippet included in your theme’s <a title="WordPress functions.php Template with 15 Essential Custom Functions" href="http:// digwp.com/2010/ 03/wordpress- functions-php- template-custom- functions/">functions.php</a> file, WordPress will display a line of copyright information (for example) to each of your feed items. Of course, much more is possible once you’re able to target hooks for <em>specific< /em> feeds. Fortunately, WordPress provides some useful <em>format- specific</em> feed hooks: |
Unchanged: <strong>Atom post feeds</strong> | Unchanged: <strong>Atom post feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>atom_ ns()</code></li> | Unchanged: <li><code>atom_ ns()</code></li> |
Unchanged: <li><code>atom_ head()</code></li> | Unchanged: <li><code>atom_ head()</code></li> |
Unchanged: <li><code>atom_ author()</code></li> | Unchanged: <li><code>atom_ author()</code></li> |
Unchanged: <li><code>atom_ enclosure()</code></li> | Unchanged: <li><code>atom_ enclosure()</code></li> |
Unchanged: <li><code>atom_ entry()</code></li> | Unchanged: <li><code>atom_ entry()</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: <strong>RDF post feeds</strong> | Unchanged: <strong>RDF post feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>rdf_ ns()</code></li> | Unchanged: <li><code>rdf_ ns()</code></li> |
Unchanged: <li><code>rdf_ header()</code></li> | Unchanged: <li><code>rdf_ header()</code></li> |
Unchanged: <li><code>rdf_ item()</code></li> | Unchanged: <li><code>rdf_ item()</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: <strong>RSS2 post feeds</strong> | Unchanged: <strong>RSS2 post feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>rss2_ ns()</code></li> | Unchanged: <li><code>rss2_ ns()</code></li> |
Unchanged: <li><code>rss2_ head()</code></li> | Unchanged: <li><code>rss2_ head()</code></li> |
Unchanged: <li><code>rss_ enclosure()</code></li> | Unchanged: <li><code>rss_ enclosure()</code></li> |
Unchanged: <li><code>rss2_ item()</code></li> | Unchanged: <li><code>rss2_ item()</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: <strong>Atom comment feeds</strong> | Unchanged: <strong>Atom comment feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>atom_ ns()</code></li> | Unchanged: <li><code>atom_ ns()</code></li> |
Unchanged: <li><code>atom_ comments_ns() </code></li> | Unchanged: <li><code>atom_ comments_ns() </code></li> |
Unchanged: <li><code>comments_ atom_head()</code></li> | Unchanged: <li><code>comments_ atom_head()</code></li> |
Unchanged: <li><code>comment_ atom_entry()</code></li> | Unchanged: <li><code>comment_ atom_entry()</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: <strong>RSS2 comment feeds</strong> | Unchanged: <strong>RSS2 comment feeds</strong> |
Unchanged: <ul> | Unchanged: <ul> |
Unchanged: <li><code>rss2_ ns()</code></li> | Unchanged: <li><code>rss2_ ns()</code></li> |
Unchanged: <li><code>rss2_ comments_ns() </code></li> | Unchanged: <li><code>rss2_ comments_ns() </code></li> |
Unchanged: <li><code>commentsrss2_ head()</code></li> | Unchanged: <li><code>commentsrss2_ head()</code></li> |
Unchanged: <li><code>commentrss2_ item()</code></li> | Unchanged: <li><code>commentrss2_ item()</code></li> |
Unchanged: </ul> | Unchanged: </ul> |
Unchanged: For more information (and more hooks), and to see where everything is located, check out the relatively short <a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #feed-template-files">feed template files</a> mentioned previously. Some of these hooks are also discussed in the <a href="http:// codex.wordpress.org/">WP Codex</a>, and there are some additional infos elsewhere on the Internets. For now, we’ve seen how to hook into feeds and some feed-specific hooks to use, so let’s continue with some practical examples of customizing feeds via your theme’s <code> functions.php</code>. | Unchanged: For more information (and more hooks), and to see where everything is located, check out the relatively short <a href="http:// digwp.com/2012/ 10/customizing- wordpress-feeds/ #feed-template-files">feed template files</a> mentioned previously. Some of these hooks are also discussed in the <a href="http:// codex.wordpress.org/">WP Codex</a>, and there are some additional infos elsewhere on the Internets. For now, we’ve seen how to hook into feeds and some feed-specific hooks to use, so let’s continue with some practical examples of customizing feeds via your theme’s <code> functions.php</code>. |
Unchanged: <h3 id="customize- examples">Examples of customizing feeds via functions.php</h3> | Unchanged: <h3 id="customize- examples">Examples of customizing feeds via functions.php</h3> |
Unchanged: Straight on then, here are some practical examples showing different ways to customize default WordPress feeds directly from your theme. | Unchanged: Straight on then, here are some practical examples showing different ways to customize default WordPress feeds directly from your theme. |
Unchanged: <strong>Add a custom logo and icon to your feed</strong> | Unchanged: <strong>Add a custom logo and icon to your feed</strong> |
Unchanged: As explained <a title="Feed your Image via Atom or RSS" href="http:// perishablepress.com/feed- your-image-via- atom-or-rss/">here</a>, a useful way to boost your brand is to include a custom logo and icon to the header area of <em>all</em> of your feeds. Just add the following code to your theme’s <code> functions.php< /code> file: | Unchanged: As explained <a title="Feed your Image via Atom or RSS" href="http:// perishablepress.com/feed- your-image-via- atom-or-rss/">here</a>, a useful way to boost your brand is to include a custom logo and icon to the header area of <em>all</em> of your feeds. Just add the following code to your theme’s <code> functions.php< /code> file: |
Unchanged: <pre><code>// add icon and logo to Atom feeds | Unchanged: <pre><code>// add icon and logo to Atom feeds |
Unchanged: add_action('atom_ head','digwp_ atom_feed_add_icon'); | Unchanged: add_action('atom_ head','digwp_ atom_feed_add_icon'); |
Unchanged: add_action('comments_ atom_head','digwp_ atom_feed_add_icon'); | Unchanged: add_action('comments_ atom_head','digwp_ atom_feed_add_icon'); |
Unchanged: function digwp_atom_feed_add_icon() { ?> | Unchanged: function digwp_atom_feed_add_icon() { ?> |
Unchanged: <feed> | Unchanged: <feed> |
Unchanged: <icon><?php echo get_template_ directory_uri(); ?>/images/ logo.ico</icon> | Unchanged: <icon><?php echo get_template_ directory_uri(); ?>/images/ logo.ico</icon> |
Unchanged: <logo><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</logo> | Unchanged: <logo><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</logo> |
Unchanged: </feed> | Unchanged: </feed> |
Unchanged: <?php } | Unchanged: <?php } |
Unchanged: // add icon and logo to RSS feeds | Unchanged: // add icon and logo to RSS feeds |
Unchanged: add_action('rss_ head','digwp_ rss_feed_add_icon'); | Unchanged: add_action('rss_ head','digwp_ rss_feed_add_icon'); |
Unchanged: add_action('rss2_ head','digwp_ rss_feed_add_icon'); | Unchanged: add_action('rss2_ head','digwp_ rss_feed_add_icon'); |
Unchanged: add_action('commentsrss2_ head','digwp_ rss_feed_add_icon'); | Unchanged: add_action('commentsrss2_ head','digwp_ rss_feed_add_icon'); |
Unchanged: function digwp_rss_feed_add_icon() { ?> | Unchanged: function digwp_rss_feed_add_icon() { ?> |
Unchanged: <image> | Unchanged: <image> |
Unchanged: <url><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</url> | Unchanged: <url><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</url> |
Unchanged: <title><?php bloginfo_rss('name'); ?></title> | Unchanged: <title><?php bloginfo_rss('name'); ?></title> |
Unchanged: <link><?php bloginfo_rss('url'); ?></link> | Unchanged: <link><?php bloginfo_rss('url'); ?></link> |
Unchanged: <width> 125</width> | Unchanged: <width> 125</width> |
Unchanged: <height> 75</height> | Unchanged: <height> 75</height> |
Unchanged: <description><?php bloginfo('description'); ?></description> | Unchanged: <description><?php bloginfo('description'); ?></description> |
Unchanged: </image> | Unchanged: </image> |
Unchanged: <?php } | Unchanged: <?php } |
Unchanged: // add icon and logo to RDF feeds | Unchanged: // add icon and logo to RDF feeds |
Unchanged: add_action('rdf_ header','digwp_ rdf_feed_add_icon'); | Unchanged: add_action('rdf_ header','digwp_ rdf_feed_add_icon'); |
Unchanged: function digwp_rdf_feed_add_icon() { ?> | Unchanged: function digwp_rdf_feed_add_icon() { ?> |
Unchanged: <image rdf:about="<?php echo get_template_ directory_uri(); ?>/images/ logo.gif"> | Unchanged: <image rdf:about="<?php echo get_template_ directory_uri(); ?>/images/ logo.gif"> |
Unchanged: <title><?php bloginfo_rss('name'); ?></title> | Unchanged: <title><?php bloginfo_rss('name'); ?></title> |
Unchanged: <url><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</url> | Unchanged: <url><?php echo get_template_ directory_uri(); ?>/images/ logo.gif</url> |
Unchanged: <link><?php bloginfo_rss('url'); ?></link> | Unchanged: <link><?php bloginfo_rss('url'); ?></link> |
Unchanged: <description><?php bloginfo('description'); ?></description> | Unchanged: <description><?php bloginfo('description'); ?></description> |
Unchanged: </image> | Unchanged: </image> |
Unchanged: <?php }</code></pre> | Unchanged: <?php }</code></pre> |
Unchanged: Note that there are two images in play here: an icon for the Atom feeds and a logo for the Atom, RSS/RSS2, and RDF feeds. Once both the code and images are in place, your WordPress feeds will be <em>uniformly branded</em> with the ultra-buff image(s) of your choice. | Unchanged: Note that there are two images in play here: an icon for the Atom feeds and a logo for the Atom, RSS/RSS2, and RDF feeds. Once both the code and images are in place, your WordPress feeds will be <em>uniformly branded</em> with the ultra-buff image(s) of your choice. |
Unchanged: <strong>Add feed <code>< link></code> tags to your web pages</strong> | Unchanged: <strong>Add feed <code>< link></code> tags to your web pages</strong> |
Unchanged: A great way to boost feed reach is to include <a title="WP Codex: Automatic Feed Links" href="http:// codex.wordpress.org/Automatic_ Feed_Links">automatic feed links</a> to the <code>< head></code> section of your web pages. When this theme-feature is enabled, WordPress draws upon its vast army of feed types and includes links to any relevant feeds for the current page view. This enables “feed-aware” devices and browsers to automatically detect your available feeds, making it easier for visitors to discover and subscribe. This theme feature is enabled with the following snippet added to your theme’s <a title="WordPress Custom functions.php Template, Part 2" href="http:// digwp.com/2010/ 04/wordpress- custom-functions- php-template- part-2/">functions.php file</a>: | Unchanged: A great way to boost feed reach is to include <a title="WP Codex: Automatic Feed Links" href="http:// codex.wordpress.org/Automatic_ Feed_Links">automatic feed links</a> to the <code>< head></code> section of your web pages. When this theme-feature is enabled, WordPress draws upon its vast army of feed types and includes links to any relevant feeds for the current page view. This enables “feed-aware” devices and browsers to automatically detect your available feeds, making it easier for visitors to discover and subscribe. This theme feature is enabled with the following snippet added to your theme’s <a title="WordPress Custom functions.php Template, Part 2" href="http:// digwp.com/2010/ 04/wordpress- custom-functions- php-template- part-2/">functions.php file</a>: |
Unchanged: <pre><code>// enable WP automatic feed links | Unchanged: <pre><code>// enable WP automatic feed links |
Unchanged: if (function_exists( 'automatic_feed_links')) { | Unchanged: if (function_exists( 'automatic_feed_links')) { |
Unchanged: automatic_feed_links(); | Unchanged: automatic_feed_links(); |
Unchanged: } else { | Unchanged: } else { |
Unchanged: return; | Unchanged: return; |
Unchanged: }</code></pre> | Unchanged: }</code></pre> |
Unchanged: Nothing else to do! Just slap it in there and enjoy your new automatic feed links. Huzzah! | Unchanged: Nothing else to do! Just slap it in there and enjoy your new automatic feed links. Huzzah! |
Unchanged: <strong>Completely remove the version number from pages and feeds</strong> | Unchanged: <strong>Completely remove the version number from pages and feeds</strong> |
Unchanged: By default, WordPress includes its version number in your feeds. If you’re always running the most current version of WordPress, there is nothing to worry about; otherwise, it’s a good idea to remove the version information wherever possible. Here’s the code to add to <code>functions.php</code>: | Unchanged: By default, WordPress includes its version number in your feeds. If you’re always running the most current version of WordPress, there is nothing to worry about; otherwise, it’s a good idea to remove the version information wherever possible. Here’s the code to add to <code>functions.php</code>: |
Unchanged: <pre><code>// remove version info from head and feeds | Unchanged: <pre><code>// remove version info from head and feeds |
Unchanged: add_filter('the_generator', 'digwp_complete_ version_removal'); | Unchanged: add_filter('the_generator', 'digwp_complete_ version_removal'); |
Unchanged: function digwp_complete_ version_removal() { | Unchanged: function digwp_complete_ version_removal() { |
Unchanged: return ''; | Unchanged: return ''; |
Unchanged: }</code></pre> | Unchanged: }</code></pre> |
Unchanged: As an added bonus, this technique also removes the version information from the <code>< head></code>section of your web pages. | Unchanged: As an added bonus, this technique also removes the version information from the <code>< head></code>section of your web pages. |
Unchanged: <strong>Delay feed update after posting</strong> | Unchanged: <strong>Delay feed update after posting</strong> |
Unchanged: Thanks to the fine folks at <a title="Publish the feed later" href="http:// wpengineer.com/ publish-the- feed-later/">WP Engineer</a>, here is a technique for delaying feed-updates for a few minutes after posting a new post or page: | Unchanged: Thanks to the fine folks at <a title="Publish the feed later" href="http:// wpengineer.com/ publish-the- feed-later/">WP Engineer</a>, here is a technique for delaying feed-updates for a few minutes after posting a new post or page: |
Unchanged: <pre><code>// delay feed update after posting | Unchanged: <pre><code>// delay feed update after posting |
Unchanged: add_filter('posts_where', 'publish_later_on_feed'); | Unchanged: add_filter('posts_where', 'publish_later_on_feed'); |
Unchanged: function publish_later_ on_feed($where) { | Unchanged: function publish_later_ on_feed($where) { |
Unchanged: global $wpdb; | Unchanged: global $wpdb; |
Unchanged: if (is_feed()) { | Unchanged: if (is_feed()) { |
Unchanged: // timestamp in WP-format | Unchanged: // timestamp in WP-format |
Unchanged: $now = gmdate('Y-m-d H:i:s'); | Unchanged: $now = gmdate('Y-m-d H:i:s'); |
Unchanged: // value for wait; + device | Unchanged: // value for wait; + device |
Unchanged: $wait = '5'; // integer | Unchanged: $wait = '5'; // integer |
Unchanged: // http://dev.mysql.com/ doc/refman/5.0/ en/date-and- time-functions.html#function_ timestampdiff | Unchanged: // http://dev.mysql.com/ doc/refman/5.0/ en/date-and- time-functions.html#function_ timestampdiff |
Unchanged: $device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR | Unchanged: $device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR |
Unchanged: // add SQL-sytax to default $where | Unchanged: // add SQL-sytax to default $where |
Unchanged: $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait "; | Unchanged: $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait "; |
Unchanged: } | Unchanged: } |
Unchanged: return $where; | Unchanged: return $where; |
Unchanged: }</code></pre> | Unchanged: }</code></pre> |
Unchanged: After adding this code to your <code>functions.php< /code> file, WordPress will wait five minutes before updating your feeds with the new content. This buys you some precious time to triple-check everything and fix any last-minute errors. To delay feed-updating for a longer (or shorter) amount of time, edit the <code>$wait< /code> and < code>$device< /code> variables to whatever you prefer. | Unchanged: After adding this code to your <code>functions.php< /code> file, WordPress will wait five minutes before updating your feeds with the new content. This buys you some precious time to triple-check everything and fix any last-minute errors. To delay feed-updating for a longer (or shorter) amount of time, edit the <code>$wait< /code> and < code>$device< /code> variables to whatever you prefer. |
Unchanged: <strong>Disable all feeds</strong> | Unchanged: <strong>Disable all feeds</strong> |
Unchanged: With all this talk about <em>customizing< /em> feeds, it’s worth asking whether or not you want to make feeds available in the first place. They’re enabled by default, but sometimes it’s optimal to disable them entirely or even selectively. Here’s the function to make it happen: | Unchanged: With all this talk about <em>customizing< /em> feeds, it’s worth asking whether or not you want to make feeds available in the first place. They’re enabled by default, but sometimes it’s optimal to disable them entirely or even selectively. Here’s the function to make it happen: |
Unchanged: <pre><code>// disable all feeds | Unchanged: <pre><code>// disable all feeds |
Unchanged: function digwp_disable_feed() { | Unchanged: function digwp_disable_feed() { |
Unchanged: wp_die(__('<h1>Feed not available, please visit our <a href="'.get_bloginfo( 'url').'">Home Page</a> !</h1>')); | Unchanged: wp_die(__('<h1>Feed not available, please visit our <a href="'.get_bloginfo( 'url').'">Home Page</a> !</h1>')); |
Unchanged: } | Unchanged: } |
Unchanged: add_action('do_feed', 'digwp_disable_feed', 1); | Unchanged: add_action('do_feed', 'digwp_disable_feed', 1); |
Unchanged: add_action('do_feed_rdf', 'digwp_disable_feed', 1); | Unchanged: add_action('do_feed_rdf', 'digwp_disable_feed', 1); |
Unchanged: add_action('do_feed_rss', 'digwp_disable_feed', 1); | Unchanged: add_action('do_feed_rss', 'digwp_disable_feed', 1); |
Unchanged: add_action('do_feed_rss2', 'digwp_disable_feed', 1); | Unchanged: add_action('do_feed_rss2', 'digwp_disable_feed', 1); |
Unchanged: add_action('do_feed_atom', 'digwp_disable_feed', 1);</code></pre> | Unchanged: add_action('do_feed_atom', 'digwp_disable_feed', 1);</code></pre> |
Unchanged: <strong>Note: </strong> Only use this function if you want to disable your feeds! Or to only disable certain feeds, comment out or delete its corresponding < code>add_action</code> and you’re good to go. | Unchanged: <strong>Note: </strong> Only use this function if you want to disable your feeds! Or to only disable certain feeds, comment out or delete its corresponding < code>add_action</code> and you’re good to go. |
Unchanged: <strong>Customize the only first post in feeds</strong> | Unchanged: <strong>Customize the only first post in feeds</strong> |
Unchanged: For our last example, here is a way to target and customize <em>only the first post</em> in your various feeds. Add the following code to <code>functions.php</code>: | Unchanged: For our last example, here is a way to target and customize <em>only the first post</em> in your various feeds. Add the following code to <code>functions.php</code>: |
Unchanged: <pre><code>// customize first feed post only | Unchanged: <pre><code>// customize first feed post only |
Unchanged: add_filter('the_content', 'digwp_customize_ first_feed_post'); | Unchanged: add_filter('the_content', 'digwp_customize_ first_feed_post'); |
Unchanged: add_filter('the_excerpt', 'digwp_customize_ first_feed_post'); | Unchanged: add_filter('the_excerpt', 'digwp_customize_ first_feed_post'); |
Unchanged: function digwp_customize_ first_feed_post($content) { | Unchanged: function digwp_customize_ first_feed_post($content) { |
Unchanged: global $wp_query; | Unchanged: global $wp_query; |
Unchanged: if (is_feed()) { | Unchanged: if (is_feed()) { |
Unchanged: $feed_type = get_query_var('feed'); | Unchanged: $feed_type = get_query_var('feed'); |
Unchanged: if ($wp_query-> current_post == 0) { | Unchanged: if ($wp_query-> current_post == 0) { |
Unchanged: return '<p>Put some custom content here!</p>' . $content; | Unchanged: return '<p>Put some custom content here!</p>' . $content; |
Unchanged: } else { | Unchanged: } else { |
Unchanged: return $content; | Unchanged: return $content; |
Unchanged: } | Unchanged: } |
Unchanged: } else { return $content; } | Unchanged: } else { return $content; } |
Unchanged: }</code></pre> | Unchanged: }</code></pre> |
Unchanged: This technique works out of the box to add some custom content (or whatever) to the first feed item, and is extendible to target subsequent posts as well. Feel free to customize the output to be anything that makes sense. <strong> Note:</strong> as-is, the custom content is added to the <em>beginning</em> of the first post. To add content instead to the <em>end</em> of the first post, switch the order of the first<code>return</code>, like so: | Unchanged: This technique works out of the box to add some custom content (or whatever) to the first feed item, and is extendible to target subsequent posts as well. Feel free to customize the output to be anything that makes sense. <strong> Note:</strong> as-is, the custom content is added to the <em>beginning</em> of the first post. To add content instead to the <em>end</em> of the first post, switch the order of the first<code>return</code>, like so: |
Unchanged: <code>return $content . '<p>Put some custom content here!</p>';</code> | Unchanged: <code>return $content . '<p>Put some custom content here!</p>';</code> |
Unchanged: Incidentally, I use this technique in my new <a title="WordPress Plugin: Simple Feed Stats" href="http:// perishablepress.com/simple- feed-stats/"> feed-tracking plugin</a> to add a custom-tracking image — works a treat! | Unchanged: Incidentally, I use this technique in my new <a title="WordPress Plugin: Simple Feed Stats" href="http:// perishablepress.com/simple- feed-stats/"> feed-tracking plugin</a> to add a custom-tracking image — works a treat! |
Unchanged: <h3 id="conclusion" >Conclusion</h3> | Unchanged: <h3 id="conclusion" >Conclusion</h3> |
Unchanged: We hope this article helps people in customizing their own WordPress feeds. The take-home message is that WordPress provides a wealth of possibilities when it comes to creating, formatting, and customizing your feeds. So be original, and have some fun 🙂 | Unchanged: We hope this article helps people in customizing their own WordPress feeds. The take-home message is that WordPress provides a wealth of possibilities when it comes to creating, formatting, and customizing your feeds. So be original, and have some fun 🙂 |
No comments yet.