views:

161

answers:

3

I have been making Wordpress themes for a year or two and keep running into things I need to keep in mind when trying to make my themes as compatible and flexible as possible with their settings, plugins, etc.

Is there a resource that keeps a checklist of all the "don't forgets" of Wordpress theming? What things do you try to keep in mind when building your Wordpress themes?

Examples:

  • Checking if the author/admin has disabled comments for a particular post.
  • Remembering to call wp_head() at the end of the <head> tag.
  • Remembering to call wp_footer() at the end of the <body> tag.
  • Using bloginfo() variables instead of setting static values for charset, html type, description, etc. so admins can modify such things in the site settings.
  • Using function_exists() before calling a function from a plugin so it fails gracefully if that plugin isn't installed.
+2  A: 

Wordpress documentation has an interesting topic addressing exactly what you're asking: it's called Designing Themes For Public Release. There's also Theme Development General Guidelines. The Templates article is wonderful too.

I don't know other official resources, but it would be interesting to add more info into those three guides. I'm interested in some other answers we may have in your question to complement them.

I'm so used to Wordpress that the examples you wrote just flows automatically when I'm developing, since using a function that outputs domain information such asbloginfo() instead of static values is a good practice in any web development.

GmonC
I was interested and hoping to get more responses as well, but the resources you've pointed to are about as good as I think we're gonna get. I was thinking of contributing this to the community wiki but not sure if that's appropriate.
JoshMock
We have a lot of "best practices" threads here, it's really appropriate. Fact is we don't have as many visibility as C# questions we got here from time to time. A "checklist" (excel, perhaps) to read before every wordpress project is a good idea. If you have a programming blog, it would be an interesting subject.
GmonC
A: 

Our firm also develops a lot of various WordPress & WordPress MU themes & we haven't found any "Official" resources, but one thing we've done is create a basic set of template files can can be used as a "standard" setup in order to speed up our development process.

Then, whenever a new theme needs to be developed, we basically copy / paste this default set of template files into a new theme folder on the WordPress install. For us, items we've included in this default setup are pre-populated header.php, footer.php, index.php, home.php, single.php, functions.php, comments.php, /images (dir), /functions (dir), style.css, /css (dir), /scripts (dir), and a handfull of other items.

Then we've also used Yahoo Grids or Google Blueprint css frames works to also speed up the css work. There's a few other items / files I'm leaving out, but should give you a general idea of what works best for us in our shop.

Tim Schoffelman
+1  A: 

A theme development checklist depends more on the intended audience for your theme. If it's beyond the basic blog and moving towards WordPress-as-CMS territory, you'd want to look into:

  • custom widgets and dynamic sidebars to make features more portable and flexible
  • support for custom fields, or plugins like MagicFields that implement the former in a whole new way
  • routing and creating custom templates for different levels of the site (ex: sub-categories get handled by category-x.php)
  • using a css framework so whoever gets to modify the styles has a higher chance of understanding it better; make sure to include ie support
  • custom wp-admin section with its own menus, pages, etc.; this is especially necessary if your theme has custom functionality that can be further customized by the user
  • use the wp_scripts and wp_styles classes and functions to add styles and scripts; this is especially important for javascript, as it prevents duplicate includes and works with dependency scripts (loads jQuery before your jQ script)
  • make sure the design of the theme doesn't look boring like everything else out there for WordPress
  • write a theme class; unless you're planning to support PHP4, use PHP5 classes and objects to make your life easier, in terms of feature inheritance and no naming conflicts. look at CodeIgniter and their singleton pattern; it makes custom globals inside template files a lot easier to manage
  • if you are (and you should be) making your theme a lot more advanced and more like a plugin, then know how to use the WP_Cache and WP_Rewrite objects so your custom queries with $wpdb (yes, you'll need to do these once in a while to get certain custom functionality) are less expensive, and your new pages (if you're rewriting urls) route correctly and your links are correctly dynamically generated, respectively.
  • last and most importantly, try your hardest to separate presentation (html) from logic (php); this gets hard as you start running custom WP loops and a good solution is the aforementioned theme class.
hlfcoding