Tutorial: Feed your sites by blogging!
Are you also the kind of webmaster with 5, 10 or even 20 web sites with the plan of making a living only through your own sites?
- How do you make sure that the content on all your sites are always fresh with related information?
- How can you make sure that new pages you write are indexed in the search engines faster then ever?
- How can you drastically increase your visitor traffic to new information you write?
- And how do you manage all this by simply writing a page and clicking one button and it’s done?
I have the solution, it is called feeding your sites from your blog.
To see an example I give you NetMarketing.us, the data on the right are coming from a feed from my blog, total automatically. This also makes the articles unique. In a later blog post I will give you all the feeds I have so you can see it.
I give you here the tutorial.
- Categorize all your web sites in different categories.
- Then make a blog and I personally recommend using Wordpress.
- Create categories on the blog that fits your sites. You can make some subcategories called “Articles”.
- Then make some posts.
- Save the following in a file called rss.inc on the same directory were you have the page to get the feed:
- Then open the URL you want to have the feed and add something like:
- To change the style of the feed just add the classes itemtitle and itemdescription to your CSS file. Or just change the last part of the script which is the HTML output, you can even have tables with background etc.
- Then do the same on your other sites.
<?php
/*
Created by Global Syndication's RSS Parser
http://www.globalsyndication.com/rss-parser
Modified by Jim Westergren
*/
set_time_limit(0);
####### The below URL is for your feed:
$file = "http://www.jimwestergren.com/category/online-marketing/articles/feed/";
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;
function startElement($parser, $name, $attrs) {
global $rss_channel, $currently_writing, $main;
switch($name) {
case "RSS":
case "RDF:RDF":
case "ITEMS":
$currently_writing = "";
break;
case "CHANNEL":
$main = "CHANNEL";
break;
case "IMAGE":
$main = "IMAGE";
$rss_channel["IMAGE"] = array();
break;
case "ITEM":
$main = "ITEMS";
break;
default:
$currently_writing = $name;
break;
}
}
function endElement($parser, $name) {
global $rss_channel, $currently_writing, $item_counter;
$currently_writing = "";
if ($name == "ITEM") {
$item_counter++;
}
}
function characterData($parser, $data) {
global $rss_channel, $currently_writing, $main, $item_counter;
if ($currently_writing != "") {
switch($main) {
case "CHANNEL":
if (isset($rss_channel[$currently_writing])) {
$rss_channel[$currently_writing] .= $data;
} else {
$rss_channel[$currently_writing] = $data;
}
break;
case "IMAGE":
if (isset($rss_channel[$main][$currently_writing])) {
$rss_channel[$main][$currently_writing] .= $data;
} else {
$rss_channel[$main][$currently_writing] = $data;
}
break;
case "ITEMS":
if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
$rss_channel[$main][$item_counter][$currently_writing] .= $data;
} else {
$rss_channel[$main][$item_counter][$currently_writing] = $data;
}
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
// output HTML
### This is the channel title which is not needed #### print ("<div class=\"channelname\">" . $rss_channel["TITLE"] . "");
if (isset($rss_channel["ITEMS"])) {
if (count($rss_channel["ITEMS"]) > 0) {
#### In the line under this one is a number, 10, that number is how many posts to display on the feed.
for($i = 0;$i < 10;$i++) {
if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
print ("\n<div class=\"itemtitle\"><a href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a>");
} else {
print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
}
print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />"); }
} else {
print ("<b>There are no articles in this feed.</b>");
}
}
?>
On the lines were you see ###, those are instructions. To get the URL of your feed just go to the category you want to give feed and add /feed/after that URL.
<strong>Latest articles on online marketing by Jim Westergren:</strong>
<br /><br />
<?php include("rss.inc"); ?>
When you do a blog post you can have it into several categories and on your feeds you can for example only take those in the Article category so you don’t get any low quality posts on the feeds.
If you write a description on “Excerpt” of the post then that is displayed on the feed.
There is also a way to have several feeds from the same blog from different categories on the same web page by just having a different name on the rss.inc and changing the following words on the script: startElement, endElement and characterData. You can see an example here.
When you have set this up on let’s say 10 sites, you will see how incredible this is.
Good luck!

Jim Westergren is a company owner from Sweden who lives together with his wife and son. Some of his interests are SEO, web development, writing and
Thanks a lot Jim, nice tutorial. I am afraid i will be harrassing you via PM if i cannot get it set up properly
GEM
Thanks, hehe.
No problem mate.
Good explanation of a powerful technique. I’ve been using this technique (although without the description) to cross promote my sites.
I’ve also used rss feeds from big name sites to keep the content fresh on my pages.
I’ve never combined the two ideas! How silly do I feel?
Thanks Jim
Nice site. Thank to work…
Great job guys…
I’m love this great website. Many thanks guy
nice and nifty idea, which i will definitely use on my sites one for music, one for tutorials and one for a foreign seo-experiments. i worried about multiple themes gave a minus, but this simple script is THE tool for me it seems. thanks a lot!
i want to earn throught blogging.
Hi Jim,
I got this going just fine, but I see “funny” characters in the feed display on the destination site .. have a look at http://datasciencesresearch.com/ which displays the feed from dsanalytics.com/dsblog/feed
Do you have an idea about what is causing this, and what I should do about it?
Also, it seems to me that google is tightening up on links that have the same text – so maybe this technique could be considered bad practice by google? Any comment?
John,
I can’t see the “funny” characters?
Should not be any problem as long as you have most of the text as unique. But if it worries you, you can take out the descriptions and only display the links.
Nice, useful tool. Thanks for sharing.
Hi jim.
I tried to include your feed on my page, http://www.microfinanceinfo.com
But nothing is showing up there. What am i doing wrong?
/Benny
I get the following error message in the error logs of the site I have this running on:
PHP Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /home/masvi/public_html/loans2/inc/rss.inc on line 8
Any ideas what is causing it and how to fix it? It appers to be working fine except the warning in the logs (and I hate looking at my logs and seeing the errors).
Thanks.
Should not be any problem as long as you have most of the text as unique. But if it worries you, you can take out the descriptions and only display the links.
PHP Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /home/masvi/public_html/loans2/inc/rss.inc on line 8
Jon Parker said this code is correct.
Good explanation of a powerful technique. I’ve been using this technique (although without the description) to cross promote my sites.
I’ve also used rss feeds from big name sites to keep the content fresh on my pages.
Jon and Web Tasarim,
My guess is that those errors is caused because the server is set on safe mode.
Hi all,
You should read my new article about this:
http://www.jimwestergren.com/display-links-to-latest-items-of-a-rss-feed/
Hi Jim,
Is this technique still good practice I have a few sites that are in need of soemthing like this but was concerned it is classified as duplicate content?
Best regards
Andrew
thanks for sharing…
thanks for sharing. I bookmarked this post.