Disable Theme Update Checks

All WordPress themes check for updates on WordPress.org, regardless of whether it was developed custom for a client or built by a commercial theme shop. This can be a problem if a new theme gets added to WordPress.org that has the same name as your custom or commercial theme.

There’s a couple ways to get around this issue. Continue reading

A New Base Theme

The first WordPress theme I ever built was a modified version of Kubrick. I think that’s how most front end developers get started with WordPress- tweaking a core theme or a commercial theme to make it fit. Building one entirely from scratch has never made a lot of sense to me and over the years I’ve used a number of different theme platforms to build on.

History

toolbox-screenshot

I had a love affair with Thematic for a couple years. It was one of the early “frameworks” and a precursor to newer projects like Genesis. It was great if the design fit into the general structure of the theme, but I often found myself writing ten lines of code in order to unhook and rehook different sections of the theme for really minor changes. It was difficult to trace functions across multiple files. Although it made me a much better developer and was excellent for some projects, overall it seemed unnecessarily complex.

Next for me was “Toolbox“. This was a base theme developed by Ian Stewart, the same developer who had started Thematic. It was the complete opposite of a framework: a real simple theme, well structured, and easy to modify. It also followed the HTML5 spec (remember when that was new?!). I built my first publicly released theme (Portfolio Press) off of it as well as several projects for clients.

After Ian took a job with Automattic, Toolbox was forked and became Underscores. More on that over here. It’s an excellent base and many of the themes on WordPress.com are built off of it. There’s a great team of developers maintaining and contributing to Underscores. The code is clean, well commented, and the model of excellent WordPress practices.

Time to Fork

Fork

However, over the last few months I’ve found myself having to do more and more work to get Underscores to where I need it before embarking on a new project. I’ve decided it’s time to fork.

This is not a bad thing of course. Underscores is intended to be base in which to build off of, even if you’re forking it to build your own new base. And a solid base theme is important for any WordPress theme developer- it allows you to move quicker because you don’t need to solve the same problems for every project.

The main reason I’ve decided to fork Underscores is because of build tools. (Though re-using patterns for menus and comments will also be helpful.)

Continue reading

The Importance of Code Review

One of the huge benefits of working as a developer on a team is code review. You’ll commit changes for a project and then another developer will review them before pushing live. This helps avoid obvious mistakes and typos in the code- but it’s also one of the best ways to learn. Invariably your code can be better or more efficient, and having another developer look at your code will expose those gaps. Continue reading

Responsive Video and FitVids

video

If you develop responsive WordPress themes, you’re likely making sure embeds and iframes resize within the container. Something like this does the trick:

/* Make sure embeds and iframes fit their containers */
embed,
iframe,
object {
	max-width: 100%;
}

But the problem with video embeds is that the aspect ratio isn’t maintained at smaller screensizes. A quick for this is the tiny jQuery plugin FitVids. Continue reading

Optimizing Google Fonts in Themes

There are a number of methods to load Google fonts in a WordPress theme, but some are more efficient than others. Google has a post about optimizing the use of the Font API. I thought I’d summarize this as it applies to WordPress themes.

Enqueue or @import?

One of the simplest ways to load Google fonts is to do a an @import from the stylesheet, but Google recommends to link directly from the head of the document instead.

Properly enqueing the font and loading it from the head will also make it easier for people using child themes to change the font without copying the entire parent stylesheet over. Continue reading

Using Grunt with WordPress Themes

Over the last couple weeks I’ve started using Grunt with all my WordPress themes. It’s a development tool that helps automate certain tasks- like generating translation files, building sass files, adding browser prefixes, and minifying scripts.

Do you think we can automate some of this?
Do you think we can automate some of this?

A tool like CodeKit does many of the same tasks (and I highly recommend it if the command line terrifies you), but Grunt gives you more control and a huge library of modules to work with.

If you haven’t heard of Grunt yet, I think the place most people start is with Chris Coyier’s article “Grunt for People Who Think Things Like Grunt are Weird and Hard“. Continue reading

Features for Theme Developers (WordPress 3.9)

WordPress 3.9 will be released this month with some great new features. I think the enhancements for media (drop-in image uploading, audio/video playlists, and better editing options) will get a lot of attention in this release- but there’s also a ton of hidden gems.

I went through 582 tickets and picked some of my favorite enhancements, focusing on the ones I think will be most interesting for theme developers.

Media Features

WordPress now has support for audio and video playlists (and audio/video thumbnail images) thanks to work spearheaded by Scott Taylor:

playlists

Audio, video, and gallery previews are available in the editor and themes can add styling to better display them. Continue reading

Portfolio Press & Portfolio+ Updates

There are a number of changes in this latest version of Portfolio Press and Portfolio+. I’m hoping the update will be seamless for most users, but there will be a few steps to complete once you upgrade.

portfolio-press-2-0

Page templates have been updated in this version, so if you have any page templates set (say for the portfolio on the home page), you may need to go to that page, re-select the template, and re-save. I wrote an update routine to do this but it won’t fire in all situations. So, just to be safe, give it a check and make the updates if needed.

Next, the theme should prompt you to change your posts per page settings in the reading options. I recommend 9. Previously, the theme had automatically controlled this, but people have often wanted to change the default (to 12 or 15). This now you gives you that control. It also fixes edge case paging bugs that some users experienced.

Finally, you’ll want to install the Regenerate Thumbnails plugin and generate new images. The theme should also prompt for this. There were a couple of image size changes in this update (especially if you had the one column layout selected)- and this will ensure that your images are at the proper size and should fix images that may have appeared blurry previously. Continue reading

Update Page Templates Automatically

In the latest version of Portfolio Press I decided to move all the custom page templates into their own “templates” directory. This helps to organize the files better and simplifies the directory. However, I also needed to build an update routine for existing users who had the page templates set at the previous paths

To do that, I needed to query for all pages that had a page template set, check if matched one of my existing templates, and then update it to the new path. Here’s the code snippet in case it is useful to anyone else. Continue reading

Post Format Views with Categories and Tags

I think it makes a lot of sense to display certain post format archives differently than standard post archives. For instance, image post formats might look a lot better in a grid view with large images rather than a traditional blog format.

It’s easy enough to alter the post format archive template, but the taxonomy views (categories and tags) will still display in the standard layout- even if all the posts are the same format.

I thought it would be great to detect what type of posts were being displayed in the taxonomy before they rendered, and use a different layout if they were all in the same post format. This way I could continuity between the post format archives and taxonomy archives- assuming they all contained the same post format. Continue reading