Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

134 PART II • Designing and Developing WordPress Themes


Keep in mind that using custom fields to do simple stuff like asides is completely
unnecessary, thanks to post formats. Use custom fields primarily for data.

RULE #3: BUILD WITH PAGES AND EXTEND
WITH CUSTOM POST TYPES
Pages have a great strength in that you can have just about as many as you want, and each one
can have its own Page template if you like. This means that anything you can do with Word-
Press can be accessible at the address of your choosing. Hence, most of my Page templates
don’t include the actual Page’s content or the traditional WordPress loop at all. Rather, they do
other things, and although they may be a bit rough to manage by themselves — you have to
hack the template file because there’s nothing more than a title and a slug in WordPress
admin — they can step outside the box.

Think about it. Say you need to show off your work stored at another service. You can include
it by using the service’s own JavaScript widget code, and you can even have it exist in itself
that way; all functionality is included. Unfortunately, the WordPress editor wouldn’t let that
code through. The solution is to just create a Page template and put the code there. The same
goes for Google Custom Search Engine result listings, for showing off RSS feed content, or
your lifestream.

The Page template is a powerful tool. Use it wisely.

Need even more control here? You can always add custom post types tailored to your needs.
Want a completely separate hierarchy of Pages like, er, pages? No problem; just create your
own custom post type mimicking Pages. Custom post types are an excellent solution when
you need more control over your content and how it is organized in the install as well as on
the site.

IS THAT ALL?
Of course, the preceding three rules don’t cover everything, but they are the main points I
tackle when I start to build a site using WordPress. Other things to consider include whether
the user should be able to subscribe to RSS feeds, what screen resolutions you should design
for, and if you need additional support for mobile devices. There’s more as well, depending on
the site you’re building, such as the search needs of the user and not to mention how heavy
the site can be — not everyone has a broadband connection. Keep an open mind and try to
look at the site from your target audience’s point of view.

INDIVIDUAL STYLING TECHNIQUES


Adding some individual styling can make both posts and Pages more interesting. At first
glance, this may seem hard to accomplish, especially when it comes to posts because they are
all governed by one single template file: single.php. Luckily, there are great methods to add a
little extra flair to the posts, thanks to the excellent addition of the post_class() template
tag and some nifty little CSS.
Free download pdf