0
votes

I am using the wordpress 3.3 with custom post type template http://wordpress.org/extend/plugins/custom-field-template/

It makes the Main editor disappear and emptied when you click load to load a custom field template it work fine with pages/posts but it is only broken with custom post type

a screenshot of what it does

enter image description here

1
it makes the Main editor disappear and emptied when you click load with custom post type. that is the issueSujith Kumar KS

1 Answers

1
votes

It's because the plugin isn't designed to work with custom posts types. If you're comfortable editing some code, it can be fixed easily.

When you registered your custom post type, you should have selected a name for an individual item, which you'll need to know when adding some code to the plugin. For example, default Wordpress posts have the name 'post' and pages use 'page'.

Once you know the name, open up 'custom-field-template.php' in the plugin folder, and scroll to line 155, you should see this:

add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'post', 'normal', 'core');
add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'page', 'normal', 'core');

If you look at the end, you'll see the plugin specifically adds support for 'post' & 'page', you'll need to copy one of these lines, only substitute 'post/page' with the name of your custom post type, like so:

add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), '%YOUR-CPT-NAME%', 'normal', 'core');

I'm assuming you should also disable the other custom fields for the CPT, just like the plugin does, which can be done with the same procedure. Add

remove_meta_box('postcustom', '%YOUR-CPT-NAME%', 'normal');

underneath the others starting around 158/159.

I think this should solve your problem, but your question wasn't very clear. Please follow up with your results.