[wp-hackers] Mirroring a custom_post to a custom_taxonomy for post2post relation [was: Time for a wp_post_relationships table?]

Lox lox.dev at knc.nc
Tue Aug 3 21:47:00 UTC 2010


2010/8/4 Otto <otto at ottodestruct.com>:
> On Tue, Aug 3, 2010 at 2:58 PM, Lox <lox.dev at knc.nc> wrote:
>> Otto,
>>
>> Taking the following case:
>>
>> - two custom post types (movies and actors) and a custom taxonomy actors.
>>
>> - the actors taxonomy should contains all actors created through the
>> actors custom post type admin ui, not more, not less.
>>
>> - then, actors term can be applied to any movie. This gives the
>> ability to retrieve all movies where an actor plays in, or, all actors
>> of a specific movie.
>
> I'd also create another "mirrored" taxonomy for movies too, to do it
> in reverse.

We'll do with a single taxonomy to simplify, if you don't mind.

>> Not automatically: if an actor get deleted, the related term in actors
>> taxonomy could also have been applied to one or more movies, and thus
>> won't be deleted
>
> True, but you might not want to delete the term entirely out of all
> posts. Perhaps you're going to recreate the actor's post and still
> want the term to exist, so it can still be tied to all his movies.

The actor post type acts like a description of the corresponding actor
term. So if the it is deleted, the term should too.

>> transistion_post_status ? Is that an action hook? If so it is undocumented...
>
> Look at the wp_transition_post_status() function. This is called
> whenever a post is inserted or updated or published or whatever. It's
> very handy.

It is, thank for pointing me at it.

I have made a proof 1of concept of the 'mirroring' system
(http://gist.github.com/507200), but I fail at updating the term name
when the post name changes. How can I know if it a post post_name has
changed in transition_post_status hook?

Regards

-- 
Lox
lox.dev at knc.nc


More information about the wp-hackers mailing list