Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Ok, so I have registered a few custom post types and a few taxonomies. Now, for the life of me, I cannot figure out the code I need to add a Custom Field to my Custom Post Type.

I need a drop down and a single line text area. But I also need to have separate fields for post types. So, say post type one has 3 fields and post type 2 has 4 fields but the fields are different.

Any tips would help I have looked at the codex and found something but cannot make sense of what I need to add to my functions.php file

share|improve this question
Use wordpress.org/extend/plugins/types – Ajay Patel Jul 30 '12 at 11:21

3 Answers

up vote 3 down vote accepted

This is probably more complicated than you think, I would look into using a plugin, specifically these two:

If you want to write your own , here are some decent tutorials:

share|improve this answer
really it would be that hard. I thought it would be as simple as adding a register code to my functions like we do with post types and taxonomies. – xLRDxREVENGEx May 13 '11 at 3:07
1  
I'll plus one this answer, but it's not too complex. The thinkvitamin.com link does a great job explaining how to add the metaboxes and save them. The sltaylor.co.uk link is an awesome tutorial on using some great coding practices. My word of caution is be careful when using the save_post hook. It's called at weird times. Make sure to have WP_DEBUG variable set to true in order to see potential errors that arise when using it. – tollmanz May 13 '11 at 3:51
Just an update i used the thinkvitamin link and that helped tremendously and it was a cake walk on setting up custom fields – xLRDxREVENGEx May 13 '11 at 23:31

I highly recommend you these (free) three plugins: "More Types", "More Taxonomies" and "More Fields" plugins, each one for creating custom post types, custom taxonomies and custom fields, respectively. Just clicking, draging and dropping, no code needed.

You can download here: http://more-plugins.se/

share|improve this answer
I don’t see a download link there. – toscho May 22 '11 at 12:49
i dont see download links anywhere – xLRDxREVENGEx May 22 '11 at 14:36

add

'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', 'revisions' ),

to your args array while registering the custom post type.

share|improve this answer
Can you please explain why this could solve the issue? – s_ha_dum Apr 23 at 14:57

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.