How to write a terrible WordPress tutorial

True, and here’s a related post I wrote earlier about Plugins vs. Without a Plugin. Still, we keep seeing such tutorials piling up everyday, even obvious ones like Google Analytics.

Why would one want to go through the trouble of copying and pasting code into their theme’s header.php file, and then breaking everything when they change their theme or when the theme gets an update? Why not just use a plugin that will retrieve the analytics profile via OAuth?

Is it considered “cool” to copy/paste all my plugins into my theme’s functions.php file? If so, I might just try it out right here on my site! And since I’m running multisite with quite a few different sites, I’ll have to do that ten times for each plugin that I need to use. Then maybe use constants to indicate which snippets I want active and which ones I don’t. *

And as soon as I end up with a 5000-line functions.php file, I can go complain that WordPress is too difficult to learn, and that it’s a pain switching themes or domains, and maybe blame Otto for absolute URLs too. *

* Sarcasm

P2 for WordPress Gets an Update!

Not much has changed from the previous version. Perhaps the most exciting change is that you can now create todo lists, by adding an “o” or an “x” at the beginning of a new line. Cool huh? If you’re new to P2, don’t forget to read this article by Matt on why we use P2 at Automattic.

San Kloud Theme by Theme.fm, now on WordPress.com

Today WordPress.com has launched a couple of new themes, and one of them is San Kloud. I remember introducing the San Kloud theme for WordPress on Theme.fm, back in August last year, and it’s made almost nine thousand downloads since then. Designed by Umit Kayabas and developed by Alexander Permyakov, San Kloud is a great theme for blogging. Congratulations to the Theme.fm team for making their first theme into the WordPress.com directory!

Dear WordPress Theme Developers, Stop Using TimThumb

Just a reminder, since this weekend I had to help out with yet another TimThumb-powered WordPress theme, broken by a “security patch” at the web hosting provider. This time it was Acquisto by Press75. The problems of Acquisto are not limited to thumbnails.

A Note About get_template_part and Child Themes

Tip: if you’re wondering why your WordPress template file (for example index.php) is not being executed, perhaps a different file (archive.php) is overriding it. Now this may sound obvious, but not when you start using get_template_part to organize your theme files, and not when you’re making a child theme.

Let’s take a quick look at the following snippet:

get_template_part( 'content', get_post_format() );

That will look for files like content-link.php, content-gallery.php and so on, and will always fall back to content.php if none of the others are found. Now, imagine you’re working on a child theme. You create content.php and content-gallery.php. You expect gallery posts to pick up content-gallery.php, which is correct.

You also expect a link post to pick up your content.php file because there is no content-link.php in your child theme, right? This is also correct, unless your parent theme has a content-link.php file, which will be of higher priority to the template loader, despite the child-parent relationship between the two themes.

It does make sense, otherwise a simple index.php file in your child theme would override all of the parent theme’s templates, because index.php is a fallback for everything. That would render child themes useless.

So when working with get_template_part (and theme templates in general, thanks Chip!) especially child themes, don’t forget to check (and preferably study) the parent theme’s template files. Also keep the template hierarchy fresh in your head every time you create a new theme template file. It tends to evolve with every release.

Diet Pills, SEO, and Theme Frameworks by Andy Stratton

Andy Stratton gave a presentation called “Diet Pills, SEO, and Theme Frameworks” at WordCamp Chicago 2011. He talked about WordPress themes, frameworks, marketplaces and a lot of related misconceptions, and some of the many problems with commercial themes including SEO, customization, child themes. Here’s a quote if you haven’t got time to watch the whole video.

There are no shortcuts to awesome!

So if your clients think that $30 themes are flexible, customizable and awesome products that will solve all their business problems, they might be wrong. Thank you Andy for clearing that out! Andy’s presentation is on SlideShare too!

About the "Lock in Effect" in WordPress Themes and Plugins

The WordPress themes and plugins market is huge these days. With all that wide range of products available, we sometimes stumble into situations where we’d like to change our mind, i.e. use a different plugin or theme instead of the one we’re currently using.

Eventually we figure out that it’s incredibly tough to replace some of the themes and plugins, because as soon as they’re deactivated, all (or part) of our data is lost, and the new theme or plugin that was supposed to replace the old ones, doesn’t see the data we previously had. So we say that we’re locked in.

This post describes the lock in effect, shows you some methods to identify such themes and plugins. Plus, if you really do have to use one such theme or plugin, we’ll cover some tips on escaping or locking yourself out.

Continue reading

Git Archive for WordPress Themes

Quick tip! If you’re using Git when developing WordPress themes and would like to create a clean “export” of the theme that would be installable from the WordPress admin interface and accepted to the WordPress.org themes directory, you can use the git archive command for that with some special arguments:

git archive --format zip --output /path/to/themename-1.1.zip --prefix=themename/ master

This will create a zip file called themename-1.1.zip with a themename directory inside from the master branch of the Git repository. This means that when the theme is unarchived either by WordPress or manually, you won’t end up with a themename-1.1 directory.