Key WordPress Functions

features, filters, tips & tricks for theme designers

take small bites WordPress is a Monster

WordPress will swallow you and your project whole if you let it. As a professional theme designer, your goal should never be to know all about WordPress. Instead, familiarize yourself with the key functions, features & filters that'll speed up your theme development process.

What's inside the guide?

Theme Features

WordPress offers many theme features that you may or may not implement in every theme. Nonetheless, you should know which features are available to you and how to register support for them.

Functions

Learn how to simplify, standardize and distill your theme's functionality into functions. Learn how to define these functions once—making them pluggable where necessary— in functions.php.

Filters

WordPress filters are themselves functions. Most input and output in WordPress passes through at least one filter. After you define functions, learn how and when to hook them into the relevant filters.

show, don't tell What's inside the guide?

The goal of any professional theme designer is to get paid—and fast—for a job well done. A job well done fast, for a theme designer, boils down to streamlining design & development processes but long before that, understanding what WordPress functionality most clients request and distilling that into a starter theme. That starter theme will usually contain the following and many more functions that are covered in the guide...

Style the Visual Editor make WYS == WYG

If you’ve taken the time to dress your custom theme up in a tuxedo and button-up shirt, it behooves you to consider putting a bow tie on the WordPress editor. What beauty you implement on the front-end should likewise exist in the WordPress back-end.

It's easy: there's a function for that!

Let's say you designed a theme that allows the use of all 9 standard post formats: aside, gallery, link, image, quote, status, video, audio, and chat.

On the front-end, the quote post format features a colored background and spots custom fonts from Typekit for the post title while the requisite <cite> tag spots a decent sans serif from Google Fonts.

Why, oh why, wouldn't you design it so that what your theme's user sees as they compose a post matches what it looks like when finally published?

WordPress sizes
  • Thumbnail
  • Medium
  • Large
Custom Sizes
  • single-thumb
  • home-medium
  • custom-size

Attachment Display Settings 1 image. 6 sizes. no problem.

Oh, cool! With add_image_size() your theme now generates 3 sizes of each uploaded image. Those, in addition to the 3 generated automatically by WordPress brings the total to 6. That's 6 different versions of every single image!

WordPress is nice enough to make its versions easy to insert into Posts. What about you?

At a minimum, your theme's user should be able to easily select and insert into posts, pages, and/or CPTs any of the 3 images defined by WordPress as well as any other image versions/sizes you define.

Get to know the image_size_names_choose() filter and improve your theme's admin UX a bit.

Conditional Content Width all oEmbeds are not equal

The WordPress Content Width functionality is useful, albeit heavy-handed. Once defined, the function aggressively sets the maximum width for all content like images and oEmbeds.

That's convenient but what if you wanted videos of a larger width in Pages than in Posts and even wider in a Custom Post Type? Currently, there is no way to define this.

There is however a feature request proposing the inclusion of the $content_width variable into the built-in add_theme_support() but if and until this gets incorporated into core, learn the WordPress way to conditionally set $content_width.

Get Out of Your Head keep your </ head > DRY

If you’ve been theming for a while, you remember having to manually call styles, scripts and define RSS feed links in header.php. No more!

Define everything in functions.php once, specifically or conditionally. Output RSS and CSS in the header and JS either in the header or footer.

Downlevel hidden or downlevel revealed stylesheets for IE? No problem. Learn how to put wp_style_add_data() through its paces the WordPress way.

Make your way to the Exif location, camera, lens, ISO... Get it all!

A picture tells a thousand words, sure. Sometimes though, the audience wants more. They want to know where you were when you took the photo, what camera you used, what lens, what ISO... The details, child, the fans want the details!

This section walks you through writing a function that harvests your uploaded images' Exif/IPTC data and allows you to give the ever hungry masses what they want: even more of you!

plus many, many more Functions, Features & Filters

when you find code in your theme getting more and more unwieldy, then its time to ask yourself, “Is there a function for that?” This guide is here to answer that question and usually the answer is a resounding YES!

If you're a pro theme designer and haven't nailed down your starter theme, these functions will get you there.