[wp-hackers] Term Meta - Trac'd already?
otto at ottodestruct.com
Thu Jul 14 03:02:55 UTC 2011
On Wed, Jul 13, 2011 at 9:37 PM, Otto <otto at ottodestruct.com> wrote:
> Yes, but that isn't something end users should be doing. That's
> something your code that implements this sort of data should be doing.
I'll give you a simple example. On the wp.org support forums, you have the
ability to subscribe to a thread or unsubscribe from it. You also have the
ability to subscribe to a tag or unsubscribe from it. These are simple
interfaces. Do you see the user object getting a term attached to it with a
set_object_terms( user-id, tag-slug ) call, or the deletion of same tag on
the unsubscribe? No, because even though you're creating terms and assigning
them to a user, the interface just says "subscribe to tag".
For something like this, I'd have a cities menu. On it, you could have the
option to add a new city. In there you'd give the city a name and possibly a
slug (or auto-create the slug). You'd have a field for a description. Maybe
a map point entry. This is all on one screen, similar to the edit post page.
You'd create this screen yourself, probably. Although you could reuse bits
of the post editor page, probably. Haven't looked at that code recently.
When you hit save, the data would all go back to your code. The code would:
a) insert the term if needed, get it if it's already there
b) create or update the post (using your CPT) and stick the description in
c) attach meta data (such as the coordinates) to the post with post meta
d) set object terms on the post with the term from step a
The bit in the theme to display same would be a simple wp_query loop. No
fuss, no muss. On creation of the new tag, he'd be able to use it on normal
posts too (assuming you registered the taxonomy for normal posts in the
first place), by simply selecting it in a drop down or something on the edit
post page. The user isn't taking three separate actions , but just the
obvious one. There's no "automation", as such. Just a normal interface that
they'd be able to use, and never see the gritty details of taxonomy
management behind the scenes.
More information about the wp-hackers