[wp-hackers] Custom Post Types and Taxonomy
The WordPress Web Warlock
wordpress at web-warlocks.net
Tue Nov 2 07:26:49 UTC 2010
Al 28/10/2010 18:30, En/na Ana Aires ha escrit:
> Hi everyone,
>
> I have defined a new custom post type and assigned a new taxonomy, to it. I
> would like to define as default 2 terms of this taxonomy when a new post is
> created. Any ideas on how I can accomplish this?
>
> There is the "Default Post Category" under Settings>Writing I would like to
> perform the same but associate to a new post type a new term.
>
> Hope you can help.... I am getting nuts with this!
Use the auto-draft post status, a useful feature from 3.0.
Just hook to wp_insert_post and if $post->post_status is 'auto-draft',
assign the default terms via wp_set_object_terms. This way you will add
them only once (when a new post is created, literally), so you can
modify them later, and have as many default terms for posts as you want.
If you don't want to hardcode the default terms (which would be a wise
option), just use options and a settings page.
More information about the wp-hackers
mailing list