search
top

WordPress SEO Fun With Conditional Tags

As I was optimizing my new website tonight (still has a long way to go) I thought I’d post about what I was doing. Little did I know the blog post would take longer than the actual work I’m posting about.

Tonight I worked on the beginnings of a footer link silo using conditional PHP tags. Those who are familiar with tweaking PHP might find this elementary to moderate, while newer SEOs without a code background will find it a little more advanced, but still easy to learn.

You will notice my footer links change, depending on which page you’re viewing:

Footer version for Home Page.

Home Footer

I introduce spiders to my sitemap, my blog + the two main categories in the blog. I will update the file later to include other pages to which I'd like to send PR from the home page.

Footer version for the SEO blog category.

Wordpress Conditional Footer

Notice I don't link to the "other" category. I will be updating the php file later to include more links to SEO-related pages.

Footer version for Non-SEO blog category.

NonSEO Footer

Notice I don't link to the "SEO" category of the blog, although I did link to the blog home and the site home. Notice the additional "non-SEO related" link to one of my other sites. This keeps it from being a "sitewide" link. I will be updating the file later to include more links to topics of interest... The idea being to link to such pages without wasting linkjuice from SEO-related posts.

…And so on and so forth. But how do you do this?

Using Conditional PHP Tags for WordPress SEO

This can be used for many applications, but in the following example we’ll just work on footers. As you’re working on the files to your WordPress blog you’ll probably have one called footer.php.

Don’t completely replace your main footer.php file or you’ll have a lot of updating to do when you want to change a global element. You’ll basically be back to static html days. Instead, just put the “different” element in its own file and call then into the footer.php file on a conditional basis.

Example of Conditional PHP Tags in Footer.php File

Conditional Tags in the Footer File

Conditional Tags in the Footer File. Notice I'm not "replacing" the footer file, but simply adding to it with various other php files. Whatever is in your footer.php file stays, so keep that limited to whatever elements you want to be "site wide".

Example of Simple Code in the Referrenced PHP Files

Home Footer Screenshot

This is the file that's being added to my home page footer. There is nothing fancy going on here - just a few div tags and standard links. That's all there is to it.

Some Conditional PHP Tags I Often Use With WordPress

  • in_category
    (Great for building link silos within your site, but watch out for posts that are in multiple categories. You may end up with more than one file included)
  • is_404
    (Key to creating custom 404 pages. Most themes already have them)
  • is_admin
    (Messages to Clients for Whom You Built a WordPress Site)
  • is_archive
    (Let them know they’re looking at archives)
  • is_author
    (I have a site where each author gets their own Ad block)
  • is_category
    (Great building link silos)
  • is_front_page
    (Especially useful when you have static home pages)
  • is_home
    (For the blog page, even when it’s not your static home page)
  • is_page
    (For pages like About and Contact. See my example screenshot above)
  • is_search
    (Custom messages like “We couldn’t find what you were searching for”)
  • is_single
    (If you want to target ALL blog posts – like I did with my Adsense links ;-)  …)

8 Responses to “WordPress SEO Fun With Conditional Tags”

  1. Tara says:

    Very nice, Everett! When I get that magical chunk of spare time to play with my blog, I will have to try this! Thanks! :D

  2. Marty Martin says:

    Great post Everett. I “stumbled” across this with my toolbar and while reading it I was like, this is a great post, then I saw it’s your blog. Nice!

    Excellent suggestions and I’ll be putting some into place soon!

  3. DazzlinDonna says:

    Good one, Everett! Great way to use conditionals for SEO purposes.

  4. Dave says:

    Brilliant! This reminds me of the Related Posts plugin that automatically cross links similar posts.

  5. Alex Juel says:

    Hey Everett, great article!

    I saved this post in my feed reader knowing that I would use it one day and today was that day. One thing I had to change in order for it to work for me was to add wp_reset_query(); to the statement in my footer, for example:

    PHP Snippet

  6. farmerebert says:

    Thanks Alex. By the way, if you use a framework like Thesis you don’t even have to go this far. Footers become editable for every page or post!

  7. Alica Odmark says:

    We really appreciate what you write on here. We try and check your blog every day so keep up the good work!

  8. Jen@ TNT SEO says:

    Have just set up a directory using WordPress, so still learning how to make the most of it, this post was especially helpful, thanks.

top