Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Say a plugin creates a custom taxonomy and attaches it to some custom post type. Is there a safe way to attach that same taxonomy to Posts?

share|improve this question
add comment

1 Answer

You can use register_taxonomy_for_object_type function and if you say that the taxonomy is created by a plugin you can use the plugins_loaded hook, to make sure that taxonomy wast already registered so:

add_action('plugins_loaded','add_custom_taxonomy_to_posts');

function add_custom_taxonomy_to_posts(){
    register_taxonomy_for_object_type('TAXONOMY_NAME', 'post');
}
share|improve this answer
    
While this is correct WordPress dictates you should register Custom Post Types & Taxonomies on the init hook IIRC. –  Cristian Jul 9 '11 at 12:04
    
accept you can't be sure when the taxonomy is registered, so you call it after the plugins are loaded –  Bainternet Jul 9 '11 at 12:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.