0

I have created 6 different custom post type, each having different post meta and taxonomies associated with it. I am displaying all different custom post types in a dropdown using get_post_types() function, Now, onchange of dropdown, I want to display associated meta fields and taxonomy.

I know that this information is not saved in DB unless a post is created, so is it possible to read this information like WordPress is reading or please suggest me if this is possible or not.

1 Answer 1

0

If I understand correctly you want to get the taxonomies associated with a custom post type object, not with a specific single post. To do that you can use get_object_taxonomies(). For example, to get the names of the associated taxonomies to "my-custom-post-type":

 $taxonomies = get_object_taxonomies( 'my-custom-post-type', 'names' );

 foreach( $taxonomies as $taxname ) {
     echo $taxname;
 }

I think you can not do the same for meta fields because meta fields are associated with a specific single post not with a post type object. You will have to hardcode the relationship between metafields and custom post type.

1
  • yes, I got it for taxonomies but I need it for the post_meta also. After lots of searching, I am also started to think that it is not possible.Thanks for your help.
    – Pritesh
    Commented Jun 2, 2014 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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