Quick Function: Inserting ads into your RSS feeds in WordPress
On my main wordpress site (this one your reading now), I like to display a single line below each RSS feed item that tells people quickly about some of my other sites.
The ad appears like this:
![]()
The code for it is pretty straight forward, and can also be used to display a copyright message linking to your site, or anything along those lines. Place the following code in your theme’s functions.php file:
function insertAds($content) {
if(is_feed()) {
srand((float) microtime() * 10000000);
$banners = array();
$banners[] = 'Banner number 1. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
$banners[] = 'Banner number 2. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
$banners[] = 'Banner number 3. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
$banners[] = 'Banner number 4. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
$rn = array_rand($banners);
$content = $content.'
<hr />'.$banners[$rn];
}
return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content', 'insertAds');
You could also replace this with banner images. Anyway, what this does is randomly select which text to display on your rss feed items. So for each article, you could have a different ad appearing.
If you wanted to use this to display only one message (like a copyright), you’d use this version:
function insertMsg($content) {
if(is_feed()) {
$banner = 'You are reading my blog. <a href="http://www.linktoblog/" target="_blank">Name of your blog</a>';
$content = $content.'
<hr />'.$banner;
}
return $content;
}
add_filter('the_excerpt_rss', 'insertMsg');
add_filter('the_content', 'insertMsg');
That’s it, like I said, it’s a quick function, but it serves it’s purpose.
SMS Notifications: A feature returns to DBStract
For some of you who may remember, there was a feature a few years ago on DBStract that let people receive notifications on their cell phones when new entries were made to their tables.
The method used was one where you entered your phone number, and provider and it would send you an SMS-email message. It worked but it wasn’t a method I was happy with, and eventually removed it.
Thanks to Twilio.com and their SMS gateway, we’ve now integrated a new solution to receiving SMS notifications.
When you create or edit a table, you now have the option to select to received text messages when someone fills out a form on your site (or where ever you’ve placed a form).
![]()
This works well for people on the go who still want to get notified when someone fills out a form, either for a support request, article submission, events, you name it.
This is also the first of several new updates DBStract will be receiving in the new little while, which I’m pretty happy about.
W3Reminder.com: website in 2 days
This week, as part of the twilio.com SMS contest, I decided to quickly whip up a reminder service that would send your phone a text when you told it to.
Even without the contest, I would have done it anyway, but it just provided a good incentive to do it now.
Once you sign up, you have two ways of setting reminders, either from your account, or from your phone by sending a text message in the appropriate format.
There’s still a little work to do, but it’s been sending me proper reminders for a couple days so that works for me
Some spring cleaning
This week I’ve been making a few changes around the blog from a new design to a new overall post structure.
There’s still some work to go on it so please bare with me for a couple of days
Project Piece is for sale
I have listed my Project Piece site for sale on Flippa. The listing is here, bidding is open for one month, and the buyout is $250.
New Wordpress plugin: YQL Auto Tagger
I like Dan’s Open Calais Auto Tagger plugin, but I found Open Calais wasn’t always quite returning the results I wanted when I used their service for specific sites.
YQL lets you send content and returns tags and they’ve been relatively relevant to the post, so I forked Dan’s plugin (with his permission of course), and modified it to use YQL instead of Open Calais, the end result was this small plugin.
With the YQL Auto Tagger plugin, you’ll never have to think of tags for your posts again. The plugin uses the Yahoo Query Language to perform semantic analysis of your post text and suggest tags for you. Add them to your post with just a click.
Based on the Open Calais Auto Tagger by Dan Grossman – http://www.dangrossman.info
WordPress Tip: Remove nofollow Attributes from Post Content
If you have posts that include the nofollow attribute on links, you may at some point decide to remove them. By default, WordPress doesn’t insert nofollow attributes in post content, but there are a variety of plugins that will insert nofollow into all links in post content. Or perhaps you have been manually adding nofollow tags to your post links for SEO purposes. Regardless of how they got there, it’s very easy to clean things up and remove all nofollow attributes from post content.
The Dev Scene: How We Built GottaLoveBacon.com Using Twitter, PHP And YQL
I love Yahoo’s Development Tools, especially their Yahoo Query Language (YQL). That combined with other services such as Twitter, make it easy to aggregate data to other website. And today I’m going to show you how to use YQL, PHP and Twitter Search to build a neat little website.
