[wp-hackers] Term Meta - Trac'd already?

Otto otto at ottodestruct.com
Wed Jul 13 19:58:26 UTC 2011


On Wed, Jul 13, 2011 at 2:45 PM, Daniel Cameron <dan at sproutventure.com> wrote:
> We built a theme that styles the site differently based on where you're at
> on a site. Think of a travel site: where San Francisco has the bay bridge as
> the background for the term archive and the individual pages, then New York
> has the park.
>
> I couldn't think of any other way to do this since we want to use term's (
> location taxonomy ) instead of building something that essentially recreates
> the taxonomy functionality with term meta.

Taxonomies exist in the template hierarchy. That would work for your
taxonomy archive cases:
http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display

Example:
taxonomy-location-new-york.php
taxonomy-location-san-francisco.php

Although for background images, your case might be simplified by just
using the appropriate body_class() styles. body_class() generates
tax-taxonomy and term-slug on taxonomy archive pages.

Example:
body.tax-location.term-new-york {
 background-image:...
}

body.tax-location.term-san-francisco {
 background-image:...
}


Doing this on individual post pages are harder, since posts can be in
more than one group in a taxonomy (like cats and tags can). For
something like that, you're going to always need some kind of custom
code to determine which term to use to decide what to do.

-Otto


More information about the wp-hackers mailing list