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

(avery) #1

CHAPTER 9 • Using WordPress As a CMS 233


The same advantage goes for custom taxonomies, also covered in Chapter 6. With these, you
can have a separate tag group for properly tagging your products, for example. This is a great
way to further control how things are sorted and found on your site. WordPress offers a great
mix of default tools, such as posts and Pages alongside categories and tags, along with the
ones you can create yourself such as custom post types and additional taxonomies. It takes
some thought to find the right toolset out of all these possibilities, but it’s worth it.


Don’t forget about portability when using custom post types and creating your own
taxonomies! Most of the time, these features are things that need to keep working
even after you switch themes, so be sure to have a plan for that. You can read more
about portability in Chapter 8, “Plugins or functions.php?.”

PUTTING WIDGETS TO GOOD USE IN A CMS


Widgets and widget areas are your friends when rolling out WordPress as a CMS. They are
perhaps not as important for the small and static company websites primarily discussed so far,
but they can be very useful for the larger ones. Take a look around online; there are numerous
sites that push out mixed functionality, especially on their front pages, and display teaser
images when it is suitable. You can do a lot of this with widgets.


Using Basic Widget Areas


The most straightforward usage is to litter your site with widget areas wherever you may want
to output something all of a sudden; just make sure that the area doesn’t output anything by
default so that it will remain invisible (as in not containing anything, including no empty
markup) whenever you haven’t populated it with a widget. However, a better practice is to
think your widget areas through and put the areas where you know you’ll need them, not
where you think you may need them two years down the road. After all, you will have
redesigned the site by then, anyway.


So you’ve got your widget areas in. Now, how do you use them? Besides the obvious answer of
drag-and-drop widgets on the Appearance ➪ Widgets page in the WordPress admin, you can
add widgets that do whatever you need. The ones that ship with WordPress are simple and
somewhat crude; the Pages widget (listing your Pages) won’t even let you display just the
Pages — it forces an h2 title out there, which you may not want. You want control over how
your content will be displayed, so if you’re moving down this route, be sure to look at the
many plugins that offer widget support; there are several available that will list just the Pages
without adding that h2 heading, for example.


The most useful widget is by far the text widget. It accepts HTML code, which means that
putting text and images in it is a breeze. This is good because if you want to show off that
special promotion (or advertise your Facebook fan page) just below the menu in the header,
you can just put the necessary HTML code in a text widget and drop it there for the duration
of the campaign, and later just remove it, and the area will disappear until you add new
content. You can find some great plugins that will help you in the WordPress plugin
repository’s featured and popular sections.

Free download pdf