WordPress tips and tricks – functions.php

Functions.php is a little known wordpress template file. Not many themes take advantage of it but , used properly, it can be incredibly powerful. The file can be used as a way to add your own functions to wordpress themes (hence the name).

One of the common misconceptions, at least based upon my experience with a past wordpress tips and tricks post, is that editing functions.php involves changing core wordpress files – meaning there will be issues when you upgrade wordpress.

I am against changing core files in wordpress. This makes upgrading a nightmare.

What functions.php does is let you create functions you can reuse in the theme. It works like a plugin file, being loaded when the theme is first loaded. You can then use the functions inside for anything you choose. For example in my first tips and tricks post I suggested using it to separate trackbacks and comments. You can also use functions.php as to implement theme control panel pages as seen in Regulus (pretty much the first theme to have a control panel).

And how do you make use of functions.php? It couldn’t be simpler.

  1. Create a file called functions.php in your theme folder.
  2. Add functions to it.

The file automatically gets included into the theme, you don’t have to do anything.

How was it for you? Let me know on BlueSky or Mastodon

(Please) Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

30 Jun 2007

WordPress tips and tricks – Custom Page Templates

Some time ago I posted the first of my tips and tricks for WordPress, and I thought it was about time I posted some more so, to start things off, here is a short tutorial on custom page templates in...
04 Nov 2006

WordPress Tips and Tricks – Post in Advance

I’m sure most people know about this but the ability to post things in advance with WordPress is absolutely great. My two blogs (this one and Binary Joy) posted 16 articles whilst I was on holiday despite me not being...
25 Jul 2007

WordPress Tips and Tricks – Custom Login Page

It’s cool to have the WordPress login page customized to fit your own website branding. This is even more significant for multi author blogs, or sites you have set up for clients as it adds that little extra something.Since writing...
13 May 2010

6 Tips to Build Better WordPress Themes

If you want to make WordPress themes, for clients, to release for free or to sell, then there are a lot of factors you need to take into consideration. Below are some hints and tips that should help ease your...
01 Apr 2015

The State of WordPress Themes #wcldn

I recently spoke on a panel at WordCamp London 2015e. Lance – who used to be the Theme Team lead at WordPress.com – asked me if I wanted to speak on a panel with him at WordCamp London 2015. I’ve...