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.

I'm trying to list custom taxonomy terms (using get_terms) from within the custom post meta code (i.e., via the add_meta_boxes action). I am getting "Invalid taxonomy" return from the call to get_terms.

I've read through as many posts in this forum and others around this and know that it has to do with not having registered the custom taxonomy yet. And that the init action happens after the add_meta_boxes action. I've seen fixes where the DB is queried directly, a solution that would work for me. I'm building a theme for a client of mine and do not want to go this route if I can avoid it.

Is there any other way to list custom terms from within custom post meta?

The reason I want to do this is to provide a client manageable list of sections to add to a custom post along with text input associated with each section. Think of a CV. The client adds a new applicant and the applicant can have any number of sections in his/her CV. They can first select (from a drop-down) the section to add, and then add the appropriate text to it.

Thanks in advance.

share|improve this question
    
Which actions do you use for the taxonomy registration and for the listing - init and what else? Also, registering a taxonomy and attaching it to a post type automatically adds that as a meta box similarly to categories and tags, doesn't this work for you? –  Mario Peshev Jul 28 '12 at 12:19
    
Theoretically you can use custom query with the $wpdb global to pull IDs and titles and connect them if the above doesn't work for you –  Mario Peshev Jul 28 '12 at 12:19
1  
there's no issue with using get_terms within a metabox callback, as that doesn't run until the page is being rendered. post the code you are using. –  Milo Jul 28 '12 at 14:37
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.