0

I have been asked to add some custom fields to an existing custom post type which was created using the Custom Post Type UI plugin. There is nothing in functions.php so how do I go about adding custom fields which will be permanently associated with the post type?

Can I add the custom fields programmatically in functions.php? WP version is 3.2.1

3 Answers 3

2

If you want the custom fields to appear on the custom post type edit page, you can add meta boxes for your particular custom post type. Check this for a detailed example. Also, if you're adding/updating custom fields conditionally, use add_post_meta or update_post_meta. All of this code can go in your functions.php file.

1

You'll have to go with what @RutwickGangurde wrote, as the plugin doesn't use the 'register_metabox_cb' argument. And as the plugin isn't written in OOP manner, you can't extend it or overwrite the function.

Anyway, there seems to be a "beta" feature where you can retrieve the php code to build the post type (see screenshots of the plugin @wp.org). You could add the callback there and then add your meta boxes with classes like the one from Rilwis for example.

0

There are also plugins that can do this including Advanced Custom Fields and "Types." I'm partial to Advanced Custom Fields (aka "ACF"), which I know works with Custom Post Type UI and has a wide variety of field-types, a good support site, and active development. More importantly, it stores the field values as custom fields which gives you a way out should something go wrong with the plugin.

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.