How to list fields in a specific node type?

I would like to generate a list of all the fields in a particular node type. Looking at the API for content_fields, I tried this:

content_fields(NULL, $nodetype); 

Unfortunately, this returns all defined fields, not just the ones specified in my particular $ nodetype.

Is there a way to generate a list of all the fields associated with a particular node type?

+4
source share
1 answer

There is no existing CCK function that does just that, but it would be very easy to implement your own:

 function content_fields_by_type($type_name) { $type = content_types($type_name); return isset($type['fields']) ? $type['fields'] : array(); } 
+4
source

Source: https://habr.com/ru/post/1383165/


All Articles