Anyone can Establish their Site as a Local Market Expert
Today’s post is my first contribution to the Geek Estate Blog, but before I dive into the details of today’s post, I wanted to take a quick second to do an intro about my background in the online world.
My name is Matthew Swanson and I’ve been in the online world right about 10 years now. I started as a web developer at Headhunter.net in March 2000 working with Shane Pike. Headhunter.net transitioned as we were bought by CareerBuilder in 2002 and I worked on the site infrastructure team building the platform for about 7 years in several different roles. Before leaving CareerBuilder in 2007, I helped to launch the CareerBuilder – Facebook partnership.
In March 2007, I joined HBN Interactive as the CTO and run House Buyer Network – our service helps connect tens of thousands of distressed and motivated home sellers with our network of top tier Real Estate Agents across the US and Canada.
When I read Drew’s post about the new Local Market Explorer plugin (LME) for WordPress, I was giddy. We were on the verge of writing one of these internally for use on some of our domain portfolio, so when I read the team (amattie, jmabe, zillow) had cranked out a new plug-in to localize data across various markets and easily show the data within a WordPress installation, I was more than excited to dig in.
In the following guide (all the scripts and XML for this example are included in a zip file at the end of this post), I’m going to share how you can easily take the LME plug-in and integrate it into your site by loading any number or cities and states from a single XML file. Translation – Create many localized content pages from just a small bit of coding and one XML File.
The site from which we’ll use as our example today is Sell My House Fast. This domain has been in our portfolio for some time as we’ve built it out with tips and ideas for home sellers that need to sell quickly. Naturally, adding in local market data into Sell My House Fast made sense, but I wanted to leverage Local Market Explorer in a more generic sense from a geographic perspective – something that would allow us to easily leverage the plug-in across the entire site. Providing the capability to reach all the states in the US as well as include US cities, all with very little hard coded data points.
The remainder of this post is a step-by-step guide on how to leverage a single XML file along with a one PHP script to control which markets you can show on your website using the Local Market Explorer WordPress plug-in. This installation guide assumes you have a standalone version of WordPress installed on your server and also have FTP and .htaccess modification permissions to your files on your server. Also, if you have some basic PHP and XML knowledge, that’s a plus.
Step 1: Download and Install the Local Market Explorer Plugin
Once you’ve got the plug-in installed, you’ll need to grab the corresponding API keys that it requires to function. This is really easy to do as they’ve included links right from your WordPress admin panel to get your API keys.
After you’ve installed the plug-in and configured it as you would like to see it on your site/blog, you’re ready to take on the next step: adding your custom XML file and integrating it into your blog. For those of you that aren’t too technical, I’m going to make this as simple as possible.
Step 2: Download and Install the ExecPHP WordPress Plugin
For those of you that haven’t used ExecPHP, it’s a really sweet WordPress plug-in. It allows you to execute PHP code within a WordPress blog post or page. You just insert your PHP code to get executed on the fly inside your blog post or page and ExecPHP will take care of it for you.
Step 3: Create a Custom XML file for the cities/states you’d like to include
We could always hard code the path to each link we want to include in our site by writing something like:
But this process can be tedious and doesn’t allow us to easily control how many cities show up on our site without writing a ton of code, or creating a ton of static html pages. And we’re all about decreasing the amount of code we have to write to get things done, right?
So the first thing you’ll need is an XML file. For our example, we’ll use a list of cities in California in our XML file – the file is named citystates.xml. Inside this XML file, we’ve listed some cities in the state of California.
Here’s a snippet:
This file will be loaded at run time via our page we create inside WordPress in just a few minutes. Now that we have the XML file with our cities defined, it’s time to put it to use. If you want more states and cities, just add them using the proper syntax as you see above with the proper xml nodes, etc.
With our XML control file created, it’s time to do the heavy lifting with a PHP script to consume the XML file. This will allow us to display the links easily on your site. We’re going to demonstrate putting this into a WordPress page, but you could just as well include this script in your WordPress sidebar as well by editing your template file.
Step 4: The PHP Page to process the Step 3 XML file you created
The name of our PHP script (page) we’ll be using for this example is load_states.php. This is a really simple PHP script (page) that basically looks at a single querystring parameter (“state”) and then loads the cities for that state found in the XML file. (Again, the zip file at the end of the article contains the files you’ll need to download to run this example)
Inside the load_states.php file, you’ll need to make a couple changes to 2 line numbers: line 12 – $_DomainName = “www.your_domain.com” and line #85 $_LocalXML = “path_to_location_xml.xml” (the path on your web server to the location xml file). Once you make these changes, upload the files to the root directory of your website.
Step 5: Time to test the Page directly…
Once you’ve made the changes to the PHP script (page) and updated your cities/states in the citystates.xml file, it’s time to hit the page directly to do a test. In my case, the page I want to hit in my browser will be: http://www.sellmyhousefast.com/load_states.php?state=California.
Note: this will be your domain, not the Sell My House Fast Domain as is with my example case.
You should see something like this is your browser:
Step 6: Create the WordPress page that will hold your PHP code.
Now that we have all the files in place, it’s time to create a WordPress page that will be the holder of the code that will load the citystates.xml file. In my case, I named the page “Sell By City” – you can see the page in action here: Sell by City
The most important part of this page is the content. You’ll want to take all the PHP code from the php script in Step #4 above and paste it into the page you create inside WordPress.
This will allow you to pass in content to the WordPress Page via the Querystring and let the ExecPHP plugin do the heavy lifting on the fly and create the content for the page dynamically. If you want to add more states or cities to your site, you can simply modify the citystates.xml XML file.
Below is how my example page looks when calling it via “Sell By City” page using the following parameter: sell-by-city/?state=California.
We’re almost done…
Step 7: Creating some SEO Friendly URLs
The final step will allow you to create some SEO friendly URLs for your site at the state level. For example, say we wanted to link to 3 different states on our site but we didn’t want to link to the pages like so:
sell-by-city/?state=California
It would make more sense to link to them directly so they would each be a unique page on the site – something like /local/California.html. That would give us a nice SEO friendly link we could use to link to within our site from maybe our sidebar or our header. To accomplish this last bit of modification, we need to make a slight change to the .htaccess file.
RewriteEngine On
RewriteBase /
RewriteRule ^local/(.+).html load_states.php?state=$1 [nc]
Notice the three lines above. Line #1 ensures you have the Rewrite Engine on (if you are using WordPress you most likely already have this enabled, same with the next line (#2)). The last line is the one that does what we want. This basically tells the web server to take all requests to the /local/STATENAME.html path and really send them over to our PHP file we created in Step #4 above.
That’s really it. In the end, you’ll have a nice dynamic linking system that will allow you to target N number of city/state combos within your site all with links directly into the Local Market Explorer data. My approach is just one of many when it comes to what you can do with the Local Market Explorer plug-in.
I hope this post has expanded your knowledge as to what you might be able to accomplish with a little creativity along with some simple WordPress plug-ins and tools. If you have any questions, please comment on the post and I’ll be more than happy to help out any way that I can! I’d love to hear how you’re using the Local Market Explorer on your site!
Download the XML, PHP and .htaccess samples from this article
Cheers, Matthew
briantercero
Posted at 08:06h, 25 AugustExcellent walk through using the Local Market Explorer plugin.
Flew through it last week, got hung up on a couple of errors. Going to try it again using your method. I am trying to get it working on our WordPressMU network of blogs. As soon as Im happy with the results, Ill post a link for everyone to check out.
Very useful post, thanks!
Andrew Mattie
Posted at 10:13h, 25 AugustThat's a very nice writeup, Matthew. Great idea to use Local Market Explorer in that way!
@Brian: What errors did you run into while trying to get it working on WordPressMU? I may be able to help you out.
jayohare
Posted at 17:48h, 26 AugustI'm getting an error when activating the plugin. The first one i fixed as the file lme-client.php has the word “template” misspelled ay about line 49 (it's temlate).
But then I get this error:
Fatal error: Class 'WP_Widget' not found in /home/content/j/a/y/jayohare/html/_Websites/Altera_WP/wp-content/plugins/local-market-explorer/lme-widget.php on line 2
WP 2.7x
Great post
Andrew Mattie
Posted at 19:36h, 26 August@jay: You'll need to upgrade to WP 2.8x in order to use the plugin. The WordPress devs introduced new functionality in 2.8 that made the plugin easier to develop.
Paul
Posted at 13:41h, 20 OctoberWow, awesome post. I am just getting started with the plugin. Will I need the ExecPHP WordPress Plugin if I am using Thesis Theme with PHP programming hooks?
Paul
Posted at 20:41h, 20 OctoberWow, awesome post. I am just getting started with the plugin. Will I need the ExecPHP WordPress Plugin if I am using Thesis Theme with PHP programming hooks?
squamous cell cancer
Posted at 17:48h, 02 JanuarySquamous cell skin cancer is the most second kind of carcinoma in the world.
proiecte de case
Posted at 22:47h, 02 JanuaryInteresting article and one which should be more widely known about in my view. Your level of detail is good and the clarity of writing is excellent. I have bookmarked it for you so that others will be able to see what you have to say.
jocuri barbie
Posted at 16:23h, 03 JanuaryI was wondering if you ever considered changing the layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?
InvestorWize
Posted at 19:18h, 25 OctoberGreat info Matt. What do you do about the content on the pages to reduce duplicate content penalties by the search engines.
[link removed]