Theme Structure Assumptions

One of the best features of WordPress is the way in which it hands off all responsibility of displaying a page to the theme. This makes WordPress an incredibly powerful and flexible platform. You can do just about anything you need to with a combination of the theme and the hooks that allow you to determine what what theme files to load.

Of course, not everyone uses all of this flexibility. A number of conventions are typically followed in theme development; mostly stemming from the structure of the “default” theme that ships with WordPress. One of these is the footer.php file.

In many themes the footer.php includes the wp_footer(); call, which in turn allows plugins to add information to that part of your HTML page. This is commonly used by analytics, widgets, etc. that need to load code in the page.

All themes should have the wp_footer(); code in them – it’s important so that plugins that need that call can work properly. It’s important enough that the theme upload process at checks to make sure that the call exists. I think this sort of sanity checking is excellent – it allows WordPress plugins and themes to work nicely in conjunction with each other.

That said…

As previously mentioned, one of the great things about WordPress themes is their flexibility. The wp_footer(); can exist in any file, not just in one called footer.php.

When a plugin makes an assumption about where to look for this call and shows an warning message like this one:

Warning wp_footer(); not found in your footer.php file, this might mean this plugin will not work!

without checking the other theme files to see if wp_footer(); is there or not, it causes the user to think that the plugin and/or theme may be broken. If you’re going to take the trouble to check files for a function call, don’t make assumptions about where you decide to look for the call. Allow themes to innovate, create new best practices and do interesting things – without concern of plugins complaining because they are expecting a certain convention.

This was brought up recently with our Carrington Blog theme1 – but it’s a bigger issue than just one person using this particular theme; hence this post for the general community.

  1. For users of our Carrington themes, I can assure you that all required theme hooks are present and anything requiring wp_footer(); has what it needs to work just fine. [back]

This post is part of the project: Carrington Core. View the project timeline for more context on this post.