• Hi. Longtime WP user here. Yes I have read the Codex about what functions.php is. Can someone answer a question and give me a better clue about what this does?

    I’ve had a slightly customized Kubrick (default theme) on one of my blogs for years. When I first got this theme (WP 1.5.3??), it didn’t have a functions.php. Recently I noticed that newer versions of the default theme includes a file called functions.php.

    So I grabbed the functions.php from a new WP 2.6 and added it to my old theme folder.

    I looked in Kubrick’s functions.php and it is full of very much code!! What does all this code do? It did not change the way my site looks at all, that I can see.

    Should I remove it? Should I empty out all the kubrick stuff (that didn’t change anything anyway), and just have an empty functions.php?

    How (or why) would I add something to functions.php myself?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You know I am not as coder, so I can give you just some summary info here, as I understand:
    the most important “function” of it is to make a theme ‘widget-ready’ – since the widgets were moved into the core (as opposed to the fisrt incarnation of them as a plugin).
    I also noticed that more sophisticated themes pack their options into it.
    And Otto42 is always suggesting to put your own functions into it, instead of modifying the core files.

    Thread Starter Dgold

    (@dgold)

    Thanks for reminding me! I figured out the reason there’s a “ton” of code in the Kubrick functions.php is this is the code to make a Kubrick Options page in your admin (that lets you change the color of the theme).

    I already customized the colors in my stylesheet and images,… so I can probably delete a lot of that stuff from functions.php

    Second thing about Widget Ready — good to know!

    Third thing — I need to learn how to do what Otto42 talks about. I’ve hacked my core files quite a few times. I wonder how I can do that in functions.php instead?

    Example – when I hack the Dashboard. I usually delete a bunch from the Dashboard (core files in wp-admin) each time a new WP comes out, because I don’t want my authors to see all those WP feeds on the dashboard. Is there some way I can do that in functions.php instead? Is that the kind of thing that can be done?

    Still trying to wrap my head around this

    it seems powerful

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    A theme’s functions.php file is a lot like a plugin, in a way. It is a special file that is always loaded when that theme is active. Meaning that it can do all kinds of things, pretty much anything a plugin can do.

    Basically, it’s intended to be a place where a theme can change the operation of WordPress in ways that it needs to do. Usually it’s used for defining widgets and adding theme options pages.

    I often suggest to put useful stuff in there because it will survive an upgrade, generally.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Please set me straight about what functions.php does’ is closed to new replies.