brandiboyd.com

freelance webmaster, virtual assistant, and general hand holder(er)

I am an idiot.

Why I should have looked at the functions.php file in my WordPress theme a long time ago.

By BBoyd • Mar 4th, 2008 • Category: Blog

Boy do I feel dumb.

I’ve played with WordPress for maybe four years now; and holding back on developing some WordPress themes of my own - or thinking I was holding back…because of something I imagined about a file I didn’t even bother to look at. And it appears I’m not alone. Every theme I’ve downloaded, looked at, or used has in it a file named functions.php. This is a common name for a file in all sorts of programs (not just WP) to put- you guessed it, functions in; so that they are all in one nice neat spot and don’t muck up a layout template with lots of non-layout markup. Thus…in my mind, this file I kept seeing in WordPress themes would be full of complex functions written by coders much more talented than I, with knowledge of languages I haven’t yet mastered enough to write functions in very well. Functions that the theme would rely upon to work properly, and that without, my themes would be somehow bad or not functional or just uncool.

Soooo…my approach to theming has been to find a theme with specific features I like (gravatars, widgets, etc.), copy it, keeping only the functions file completely intact as copied- assuming that it held some special secret sauce I couldn’t make, and then to create a fresh theme based on the copied one, as suggested in the WP codex. And yeah…I didn’t really ever take a look at the functions.php file. I know. I have no valid excuse.

So, yesterday I was tweaking some things in the theme I’ve been working on for All American Pilot Car Services and having some real trouble finding the solution to a design problem on my new index page. I’d installed Mimbo2.2- the theme I re-skinned for this site, activated and configured all my plugins, copied the source of the index page to get the classes and id’s for the css, and created a new index with them. Then I made a copy of the mimbo theme folder, renaming it, and completely deleted all the page files - leaving functions.php in place and working with the new index page and Darren’s and the various plugin css files in my browser to start out. I got about halfway through and hit a brick wall positioning some elements with my fluid layout the way I wanted. I spent hours looking for the right class or id to style, or for an element in the HTML that was causing my issue, or for an errant comma or missing bracket, opening each file one by one and combing through it character by character. Finally, I’d reviewed every file available but functions.php, and there it sat staring back at me from the ftp server. I didn’t want to, but I had to open it and see if I could figure it out. So I took a break, readied myself for a long sit, and clicked open.

I found a function to register the sidebar. Ok. I get that, roughly. Cool. Moving on. Next I came to comments that let me know the next function was for changing the image color in the Kubrick theme header from the admin end. Only this was the function.php file from the Mimbo 2.2 theme, which doesn’t have the Kubrick header. So I read on sure that there would be more functions to follow, figuring that like I would if I wrote functions, Darren left the functions from whatever theme he started with in place and added to them. Only there weren’t any more functions. Just the sidebar registration and the kubrick header image color changer (which IS the kind of function I expected this file to be chock full of). Huh. So, I went to look at some other themes I’d downloaded in the past few years. Similar results…register the sidebar, not much else; some had deleted the Kubrick header function, some had not; but it appeared in general that most theme-creators had taken the same approach I had to functions.php- just duplicate and don’t mess with it. Wow. I felt like an idiot. An idiot with company, but an idiot, all the same. A lazy one.

And of course, my problem wasn’t in there anyway. It was in a typo in my new index. One that I missed about a hundred times in poring over all the files. The kind that makes you want to just scream and pull your hair out, it’s so obvious. But by the time I found it I was so glad that I’d actually broken down and taken a look at the functions.php file in my themes, and so humbled by what I’d discovered, it didn’t matter. I fixed it and moved on to the next problem in a hurry. I’m really looking forward to finding some free time to finally make those themes I’ve been waiting to make now that I know I don’t need some uber brain power or level of programming that I don’t yet have to handle the special knowledge within the functions.php file.

I’m not sure which I feel more idiotic about. Second guessing myself, or just not taking the 30 seconds to actually look at the code….

BBoyd is a 33 year old freelance web designer, webmaster, and jill-of-all-trades. A proud Austinite, a single mom of an almost college age daughter, and a creative, crafty, geeky type. Also, a bit silly.
Email this author | All posts by BBoyd

Leave a Reply