Ben
Ben is a lifelong Nintendo fan who likes to build websites, and make video games. He buys way too much Lego.
WordPress and Games
Here on Binary Moon I have added a notice that tells people if a specific post is in the Art Directed category, so they know to visit my site to see something styled a bit differently, and over on WPVote I added an automatically generated thumbnail to show a screenshot of the website that has been written about. Check out the WPVote feed to see what I mean.
Both of these things are an excellent way to engage people more with the content, and there is no limit to what you could do. For example you could use this very simple code to:
The code to do this is really simple as well. It makes use of the filter system that is integrated into WordPress to hook into the content, make some changes, and then output it again with the new additions.
Using a filter is easy, you just have to add some simple code to the functions.php file found in your theme. The basic usage looks like this:
function contentModifier ($contentToFilter) {
// do stuff with content
return $contentToFilter;
}
add_filter('filterName', 'contentModifier ');
There are actually loads and loads of filters available, and there’s a list of all the WordPress filters on the Codex. Many theme frameworks also add their own custom filters such as Elemental has around 33 of them (listed on the Elemental theme documentation), which allows you to change the theme without touching the code.
To add custom stuff to my RSS feeds I made use of 2 filters, that both used the same modification function. The filters are called the_excerpt_rss and the_content_rss. When the filter is executed the data to be modified is passed to the function you specify. The content can then be altered however you wish and returned.
In this example I am going to link to my Twitter page at the bottom of the content:
function bm_rssContent($content) { $content = $content . '<p>Like my blog? Why don't you <a href="http://twitter.com/binarymoon/">follow me on Twitter</a></p>'; return $content; } add_filter('the_excerpt_rss', 'bm_rssContent'); add_filter('the_content_rss', 'bm_rssContent');
So what would you use something like this for? I bet you have lots of idea that I haven’t considered.
love this. the rss tricks are so dope.
Definitely useful, nice post!
I’m trying this method but it doesn’t work. I think old posts doesn’t affected. I don’t created any new post after adding this code snippet to my functions.php file.
If you use feedburner or some other similar service then it will take a little while for the feeds to update, but they will update eventually.
I’m looking through blogaddress.com/feed/ not Feedburner. Also i don’t using any plugin for redirecting feed to Feedburner.
By the way i’m using Wp 2.9.1.
hey buddy do you mind to update your plugin ?/
http://wordpress.org/extend/plugins/bm-comment-highlight/#post-2828
Hi – this functionality is built into WordPress core now so I don’t see the point in updating the plugin.
I try to made a plugin for show youtube thumbnails preview in the facebook RSS, but it’s not perfect (you can rewrite it, if you understand it π
http://jaiunblog.com/2206/image-youtube/ (<- you can comment at this page not here ;Β¬))
Hi Ben, i know this is off topic
but could you make like a digg button for wpvote?
so i can add like a “digg my post” or “tweet my post”
in my site. I’m sure that it will be awesome if you could do that.
it will put more interaction to the user
If there’s already a feature like this in wpvote,
i look everywhere for it but couldn’t find it
Dian
Hi Dian. This is on my todo list, but it’s a complex feature to develop and I am currently not entirely sure how to do it… but I do have some ideas π
Good luck on developing it, i’m sure it will be awesome if it’s implemented π
Ben,
This code will work with WordPress Feeds, but when exporting to Feedburner, it will fail. I was doing a similar thing on a client’s site and it was not working. Then I used Joost’s plugin for guidance to see what he was doing.
You would actually have to add it to the content of the RSS feeds.
Did a whole write up How to Manipulate Your WordPress RSS Feeds
Hey Syed – thanks for the comment. My code does work on feedburner though. I am using it on WPVote to include website screenshots. You can see it here: http://feeds.feedburner.com/WordpressVote
It doesn’t show. Not for me at least. Below is the screenshot for your FeedBurner Feeds (WPVote)
http://imgur.com/rnXXC.jpg
Hey, thanks for the tutorial. It worked perfectly. Had a quick question though – after I get the extra content to load into the RSS Feed (for example if I’m viewing it in Safari), when I actually embed the RSS Feed on a website, that extra info goes away. Do you have any idea why that would happen? It’s been about 4 days as well – and I’ve tried clearing my cache several times. Thanks!
I’m late to this party but I plan to use this trick to auto generate the content of the post based on content from custom fields. Hopefully it works as envisioned. π