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 in March 2000 working with Shane Pike. 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.

Easily Add API Keys to Local Market Explorer

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:

Marietta, GA Real Estate Data

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:

XML for Local Market Explorer

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 = “” 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:

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:

Results from the Load_States.PHP call

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.

Viewing a page on Sell My House Fast

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.

Viewing Local Market Data in 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:


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