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 😉  …)