Ok, so today newsPage got another quick update, as I added a feature that was requested by a few users.
That feature is the ability to choose to open links from RSS feeds in new windows.
I promise to keep the updates down for the next couple days.
by Roger Stringer on March 9, 2009 in Articles
Ok, so today newsPage got another quick update, as I added a feature that was requested by a few users.
That feature is the ability to choose to open links from RSS feeds in new windows.
I promise to keep the updates down for the next couple days.
by Roger Stringer on February 9, 2009 in Code
Recently, some clients of mine decided to move a site that was fairly established on it’s own platform to wordpress. So I was faced with importing all the old articles into wordpress.
For the import, I decided to set up an RSS feed that contained the content, and so I imported all articles to the new system.
But then, we found a problem. The old site, used article.php?id=ARTICLEID, whereas the new site used /article-name so if you went to an article from the old site, you got a 404 error. This caused a problem when the site sent out thousands of emails a day, and was used as a central area of conversation for it’s industry.
We were faced with setting up 301 redirects for over 2000 articles, or finding another solution.
After some research and testing, I noticed that wordpress stores the original article’s address as the new article’s permalink during the import. So we wrote a quick little function that could check for old article references.
function redirect_fix() {
global $wpdb;
if ( isset($_GET['id']) || $_SERVER['QUERY_STRING'] != "" || substr($_SERVER['REQUEST_URI'],-1) == "?") {
$likestr = "?id=".$_GET['id'];
$likestra = explode("#",$likestr);
$likestr = $likestra[0];
$querystr = "SELECT wposts.* FROM $wpdb->posts AS wposts WHERE wposts.guid LIKE '%".$likestr."'";
$pageposts = $wpdb->get_results($querystr, OBJECT);
foreach ($pageposts as $post){
$url = get_permalink($post->ID);
if( count($likestra) > 0) $url .= "#".$likestra[1];
wp_redirect($url,301);
exit;
}
}
}
add_action('plugins_loaded','redirect_fix',0);
I placed this in the functions.php file of our theme, and set it to work. Now, whenever someone goes to the site using an old URL, they are given a 301 redirect to the new URL. Since we put this fix live over a month ago, we have had no problems with the site.
This tip is just something to show you an idea for handling importing an old established site into wordpress and how to address some of the issues that can come up.
This method has worked well for me on the site I used it with, and may help you out later too. To change it for your needs, change the reference to id to whatever field your site used to use. so that if you used to have a site that called article as the id tag, then you would replace references to “id” with “article”, as shown below:
function redirect_fix() {
global $wpdb;
if ( isset($_GET['article']) || $_SERVER['QUERY_STRING'] != "" || substr($_SERVER['REQUEST_URI'],-1) == "?") {
$likestr = "?article=".$_GET['article'];
$likestra = explode("#",$likestr);
$likestr = $likestra[0];
$querystr = "SELECT wposts.* FROM $wpdb->posts AS wposts WHERE wposts.guid LIKE '%".$likestr."'";
$pageposts = $wpdb->get_results($querystr, OBJECT);
foreach ($pageposts as $post){
$url = get_permalink($post->ID);
if( count($likestra) > 0) $url .= "#".$likestra[1];
wp_redirect($url,301);
exit;
}
}
}
add_action('plugins_loaded','redirect_fix',0);
It’s that simple to address, and has worked well. Since then I’ve used this trick on my own blog when I merged 360affiliate.com with this blog.
by Roger Stringer on January 20, 2009 in Articles
Yesterday, over at css-tricks.com, Chris published an article by Jay Salvat about using PHP and jQuery to create a clickmap on your site. I started playing with that idea and decided to make it into a wordpress plugin.
A couple hours of coding, and several versions later, I happily finished WP-Clickmap v1.0
This little plugin will store each click made on pages of your site in a database, and from there, you’ll be able to go to your blog’s admin section and view the various pages. See what is popular with your visitors and what’s not. It’s had some interesting results on the sites I’ve run it on so far, and wanted to share it here for people to download and play around with.
For anyone who is wondering about the advantages of clickmaps, clickmaps let you see your site from a usability perspective. Your clickmaps show literally every click a user makes on a particular page. Every click is loaded into the database and over time a visual representation of collective clicks gives you an overview of the hotspots on the page.
While it is interesting to see links that are being clicked on, it is even more valuable to see where people are that are not links. Why do people keep clicking on the middle of my page?
WP-clickmap is based on the original idea Jay Salvat published on his blog and on css-tricks.com. Thanks to Jay and Chris for the idea.
by Roger Stringer on November 6, 2008 in Articles
Ok, so today I started to redo the theme that this blog is using, it definetly lends itself nicely to what I want to do here, and with a few more tweaks, will be right where I want it.
Some things I’ve done to the theme, was the original twitter feed to the right was javascript based, so I changed it to use PHP and added a caching method to it so that it only updates every hour.
by Roger Stringer on April 12, 2007 in Articles
Lately, I’ve been experimenting with some new ideas and approaches.
I built a new framework last month for some rapid PHP development and my first project was a stats system that I am using to record some analytics for a couple sites.
When it is ready, the site will be released for others to join, but for now, it is just for myself and a few other colleagues to play with.
I’ve gotten the reports working to the point that I can view trends over the past week to see what pages and keywords are getting traffic and which ones are not. This can have a big impact when it comes to affiliate marketing to see which pages of a site work and which ones don’t.
I’ve also gotten a few other reports worked in that are pretty unique to analytics sysems, but I’ll wait til the site is done before getting into them all
Roger Stringer is a Kelowna-based web developer, chef, writer, entrepreneur and family man. He is the founder of TheInterviewr.com, the world's first Interview Relationship Manager , a co-founder of DBStract, a web-based webapp builder and the founder of Freekrai.net, a web development studio that focuses on building webapps.
Read more about Roger on his about page, or follow @freekrai on Twitter. You can also drop him a note via the contact page.

© 2012 Roger Stringer. All Rights Reserved.
A Freekrai.net website.
