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.

Was it good/ useful/ a load of old rubbish? Let me know on Mastodon, or BlueSky (or Twitter X if you must).

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

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...
15 Sep 2023

Building a Control Panel for my Websites

I run a whole stack of websites, and as the number keeps growing, I was finding it harder to manage them all; so I decided to make a central control panel to manage them all efficiently. In this blog post,...
27 May 2013

WordPress: 10 Years Young, What Does The Future Hold?

WordPress is now 10 years old. I started using wordpress 9 years ago – which means I joined the WordPress community early on. The reason I chose WordPress is simply because of the fabled 5 minute install process – I...
20 Jul 2016

Empathy in Web Design

I wasn’t able to make WordCamp Europe this year, but they’ve been really quick at getting all of the talks online, and so I have been watching some of them – and this one stood out.Morten Rand-Hendriksen is an experienced...
05 Jul 2016

Dogfooding a New WordPress Design

Eating your own dog food, also called dogfooding, is a slang term used to reference a scenario in which a company uses its own product to test and promote the product.Wikipedia – DogfoodingThis is another thing on the long list...