About 90% of the sites I build are custom Genesis child themes (the other 10% being modifications of existing Genesis child themes). Over the past year I’ve developed my own base child theme that I start from. It contains code that I use often and structured in the way I prefer. When building a site, I uncomment features as I need them, and when I’m done I delete everything that’s still commented.
- Functions.php – Described below
- style.css – Copied from the latest version of Genesis with the table of contents removed and the child theme information at the top
- screenshot.jpg – Used on the Appearance > Themes page. Usually put the client’s logo or a screenshot of the site.
- /images – Empty, where images will go
- /lib – Library which contains…
- /metabox – All the code required to create custom metaboxes. I never edit this folder
- /functions – When a function or series of functions become really long, I move them to their own file in here rather than leave them in functions.php. It comes with…
- shortcodes.php – Some useful shortcodes and turns on shortcodes in widgets. Hint: Use shortcodes for the Site URL in sidebar widgets so they still work when the site is migrated. Since sidebar widgets store their data in serialized array it’s really hard to update these URLs in the database.
In the functions.php file I have a large theme setup function, as recommended by Justin Tadlock. Inside my setup function I have functions that do the following:
- Remove unused backend pages (on). By default it removes the Links page. You can use it to remove any backend pages you don’t want the client seeing.
- Customize Menu Order (on). Rearranges the top menu to be: Dashboard, Pages, Posts, Comments, Media.
- Set up post types (off).
- Set up taxonomies (off).
- Set up metaboxes (off). I should also mention that if any of these functions get long (ex: creating 10 metaboxes) I move them to their own file in /lib/functions.
- Remove unused page layouts (off). Select which page layouts you’d like offered. You can also create your own layout options.
- Setup sidebars (off). It has the secondary sidebar removed, how to create a new sidebar, and how to turn on footer widgets. All options are commented out.
- Setup shortcodes (on). It pulls in the shortcodes.php file.
- Remove edit link (on).
This should give you an idea as to how I personally organize my code. I sort it by backend to frontend, and on larger sites I break down frontend to Frontend General, Frontend Posts, Frontend Events… When a function gets really long it’s turned into its own file in /lib/functions and referenced in the functions.php file (like shortcodes.php). I also often create WordPress widgets, and put them in /lib/widgets.
Hopefully this is helpful. I highly recommend creating your own base child theme based on what you use most often and your coding style.