Support » Themes and Templates » functions.php in default theme – what is it?

  • Pardon my ignorance. There’s a file called functions.php in the default Kubrick theme for WP 2.0.1. The Codex says “Theme Functions — Themes can now include a functions.php file that will now be loaded like a plugin attached to the theme.”

    What does that mean (roughly)?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Just what it says. It’s a file that can contain PHP functions your theme needs to operate. It looks like it’s just a way to separate them from the main theme files for convenience sake.

    I could be wrong…

    Cal Evans

    The main purpose of a theme’s functions.php is that WordPress loads it (just after plugins), and makes the code in it globally available to more than just that theme’s templates. It’s this feature which allows the default theme to provide its “Header Image and Color” settings tab under Presentation in the WP admin.

    hmmm… I see what you mean about “Header Image and Color” for Kubrick. That’s neat, I’d say.

    What if I make a new theme? (I’m basically asking if I can safely ignore this file when I make my own theme – the answer looks like “yes”).

    (…the answer looks like “yes”)

    {Kaf nods affirmatively}

    The only theme template you can consider *necessary* is index.php. Everything else is optional (Ok, maybe not style.css. Really do need the template name and such, which is embedded in the stylesheet).

    In what order are the template files called when a functions.php file exists in the theme’s folder? Is it called before all other files? 🙂

    BTW, you can use functions.php to make your own template tags, I use it to insert the search form whereever I need it, or a not found message. It’s brilliant.

    I also wrote a function to give you human times, like “2 hours ago” or “4 years ago”.

    TigerDE2: I think so yes. At least, it’s called before header.php. You might find you have a few problems with variables though, you need to declare them as global inside the function you want to use.

    Thanks, maerk.
    I just wanted to know because I want to i18n a (third-party) theme, and you’ve to “register” the gettext namespace before any gettexted strings…

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘functions.php in default theme – what is it?’ is closed to new replies.