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.
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
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.
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?
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.
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
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.
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!