Skip to content

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.


Web Design

Ben View All

Ben is a lifelong Nintendo fan who also likes to build websites, and develop games. He also buys way too much Lego.

33 thoughts on “WordPress tips and tricks – functions.php Leave a comment

  1. I am looking at using that file to create some custom functions to override/mimic standard wordpress function. Should make additions a lot easier.

  2. functions.php is pretty slick, I’ve added a recent comments as well as a related posts function, but now I’m stuck with a dropdown tree menu function.

  3. Hello, I have been using your Regulus theme since creating my blog (on because I really love it for its simplicity and straightforwardness, b/g color selection, tabs and the ability to change the header. However, I seem to be limited by the fact that there is no plugins function or am I missing something? (I would like to be able to insert video or a java poll please.) *Help!*

    Thanks in advance.

  4. Blend, Iwo, Daniel – thanks 🙂

    Luke – it’s a great idea. Without this I wouldn’t have been able to do the admin page in Regulus. It opens up stacks of possibilities.

    KVilla – I don’t have any control over the features allowed on You would do better to ask them for help. The issue is largely a security one. They can’t allow people to do whatever they want as it would potentially open up security issues. If you really want to customise things they you should pay for some webspace and set up your own, self hosted, blog. Then you will be able to do whatever you like.

  5. Thank you for the quick response, Ben. I am new to Can you please confirm if the plugins option is only allowed on, therefore all blogs hosted on its free site disallow plugins? Is there another way at showing a video (either as .swf or .wmv) as a post? Currently, I have an animated gift posted in one of the tabs at the site, but I would very much love to be able to show the longer video file instead.

  6. KVilla – you are correct that plugins don’t work on The best way to run wordpress is self hosted with the download from but obviously you need webspace for that. I would suggest asking for help on the forums as I don’t have much experience with the system over there so can’t really suggest anything.

    Hope you get it all working

  7. Pingback: Weblog Tools Collection » Blog Archive » Managing Trackbacks and Pingbacks in Your WordPress Theme
  8. Im glad if i find a “trick” or tip to put extra fields in comments.php

    How made this, run a query ?
    what happened with the comments.php to make it work ?

  9. hi i am new to this site.i am a 20 yrs and working as a php trainee.i want the tips to improve my knowledge

  10. Hi,
    Your blog design is truly wonderful and very novel. The first thing I noticed about it was the fact that the page scrolls down but the Adsense in the sidebar remains in place. What a great implementation! I would really it if you cold share this trick with me…

  11. Hi Ben,

    Your post makes this all sound so easy, but I’m stuck on step #1. Where do I find the theme folder?

    My site is still hosted at and doesn’t have its own domain name yet. Is that why I don’t see anything called theme folder? I have no idea where to find/create the functions.php thing.

    Your help is appreciated.


    • Hi JoAnna – Unfortunately if you use then the changes mentioned in this tutorial are simply not possible. You would need to buy your own webspace and download and install WordPress yourself for to be able to make the changes I mentioned.

  12. Pingback: WordPress Tutorial: Permalink Structure › Binary Moon
  13. I’am not trying to be rude, but this is a useless post. At the very least provide some kind of information on “how” to edit the functions file.

    I followed the instructions at the site, added my own functions, and now I’am getting a “header already sent” error message.

    The #2 in the above post – Add functions to it. – does not seem to be that easy.

  14. Hi Ben,

    For the first time I understood the functions.php, thanks to your neat post.

    I stumbled upon it while I was trying to add a short code to my site. Worked like a charm. However, there is minor problem. If you could help. I will try and explain my case as clearly as possible.

    I use a theme called ‘Mystique’. It has an option to add custom functions to functions.php (how sweet). I add a small piece of code, as instructed by the author. The code works (I guess). My problem is, the output/display is shown right at the top of the page. 🙁 There goes the neat and clean layout. I wish to have it at the bottom of the page. Like a footer. What do I do?
    The code is from freerelative links site. They have sent me 4 php files and instructions to add on the home page.

    Thanks in advance. Keep doing good work, if not money, at least you will accumulate good Karma points by helping total idiots like me. 😀

  15. Okay for a complete newbie, where is the theme folder? I really want to do this myself and connect the “facebook like” plugin on my site. Can you break it down for a newbie customizing a free wordpress site? I don’t see “plugins” in my dashboard yet either. How do I make that appear? Could some themes not allow plugins?


    • Hey James,
      When you log into WP, there’s a menu on the left hand side (in the dashboard). It could be collapsed, in which case you have to click a >> icon at the top to expand it. There, you’ll find the “Plugins” option towards the bottom of the menu and you’ll find a variety of facebook like and facebook connect plugins that will probably suit your purposes. 🙂

  16. Hello everyone,

    First of all I have to say I’m a technology dummy and I’m very sorry if anyone finds my questions stupid. I’m currently using my own webspace hosted at Godaddy and powered by WordPress, so according to what you say above I should be able to find the functions.php file.

    My problem is: I’m using a theme called Treba and want to widgetize and enable custom-background. However this theme doesn’t have a functions.php file. You say that I can “create” one but honestly I don’t know how to create it. Please help me step by step so that I don’t feel lost on the way.

    Your help is much appreciated!!!


  17. Pingback: Optimizing WordPress 404′s
  18. Good post! I am learning how to design a good wordpress blog by myself, your post is very useful for me, thank you very much!

  19. I’m new to this too and struggling a bit how to create this file under the ‘Themes’ section. any help would be great.

    Great article by the way.

  20. I’m new to this too and struggling a bit how to create this file under the ‘Themes’ section. any help would be great.

  21. Hi,

    Can i reuse the class’s mathods into the functions.php file ?
    If so, please give me any one example.


  22. Will adding this function.php work to add posts and pages in WordPress with .php code? I wanted to add some pages with .php, but I don’t want to use the WordPress “allow .php posts and pages” plug-in because, I tried it on a site and it cause the site to totally crash. Fortunately, I had just started the site, so rebuilding it was no big deal.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.