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

How to Use the WordPress Menus

I’ve been getting a lot of questions about how to use and set up the WordPress menu navigation, so I created this video tutorial to walk you through it. These menus are a new feature in WordPress 3.0, and you’ll know if your theme supports it by clicking on Appearance > Menus.

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

Hiding Page Templates in the Admin

With the latest version of Portfolio Press I needed certain page templates to only be available if the Portfolio Post Type Plugin is installed. This is because those page templates work specifically with portfolio post types and are ineffective without the plugin.

Unfortunately there is no filter for page templates in core (though there are some patches). The PHP workarounds I’ve seen are convoluted and brittle, so I decided to tackle this instead with javascript. Continue reading