Michael Gray - Graywolf's SEO Blog |
Thesis Tutorial: How to Conditionally Change Content Posted: 20 Oct 2010 07:30 AM PDT In yesterday’s post, we spoke about why you would want to change your content based on traffic intent. In today’s post, I’m going to give you a basic framework about how to do it. This post is written as a Thesis Tutorial, because working with Thesis is just easier (see my Thesis review), but you can easily adapt the code to any website or theme. OK. Like all Thesis customizations, we’re going to need to open up the custom_functions.php file. In this example, we are going to offer different social buttons based on where the user came from. If they came from a social site, we’ll show the interactive buttons with counts/votes. If they came from anyplace else, we’re going to show static graphic icon buttons. For the website I’m using I put the buttons under the author byline, so my code will go in that function (if you are going to copy and paste, wait until the end for the final code so you get all the semicolons and parentheses).
I’m going to make sure the buttons only appear on single pages so I’ll need the following bit of code:
Ok now we get to the programming. We’ll need two variables and one array. The variables will hold the referring URL and a flag that tells whether that condition is true, and the array will hold the list of sites we are checking against.
So what we want to do next is take the list of social sites and see if any of them are in the referer. If they are, we set the flag to true.
Now, if you’re a stickler, you could make the case that, if Twitter was in the filename and not the domain, we could get a false positive, and you would be correct. I just don’t think that’s going to happen often enough to be a real concern. OK so now we know whether the referring site is any of the social websites we want to trap for. If it is, the $CUsocial variable will be ‘true’ so we’ll need this bit of code:
The code above has a placeholder for the buttons you can get from places like digg, stumbleupon and facebook. Since there are so many tutorials and instructions from the original websites, I just left placeholders. Here’s the full code:
The following is just a starting point and can be re-used and expanded upon. For example, if you want to trap for search engines, here’s the extra code you would need:
But you can use the code all over the site content, header, sidebar, etc. You can combine it with date based triggers, or there are many, many different possibilities, if you spend time playing with the code. This post originally came from Michael Gray who is an SEO Consultant. Be sure not to miss the Thesis WordPress Theme review. Related posts:
Advertisers:
|
You are subscribed to email updates from Michael Gray - Graywolf's SEO Blog To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Niciun comentariu:
Trimiteți un comentariu