views:

212

answers:

2

I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom fields that will later be read from the template. The plugin adds an additional meta box to the "Edit Post" screen which is responsible for manipulating these values.

My problem is that the custom fields generated by the plugin also show up in the "Custom Fields" box. Ideally I would like for the custom fields generated by the plugin to be managed separately from any other custom fields for that same post/page.

Is there a way that I can filter fields specific to my plugin to prevent them from being displayed in the "Custom Fields" box? I have yet to locate any action or filter that will let me capture and manipulate those values before they are rendered on "Edit Post".

A: 

If you take a look inside the function _list_meta_row() (around line 2500 in wp-admin/includes/template.php), you'll see it skips post meta that is a serialized array or object.

So, if you can see fit to store your plugin post meta as an array or object, it shouldn't show in the Custom Fields box.

TheDeadMedic
apologies on the (very) late response. The method you describe above does indeed exclude the array/object from the listing of each custom field for that post, though it does still leaves the key in the drop-down list at the bottom of the "Custom Fields" section. Honestly, I'm willing to live with it. Thanks!
Kyril
I just took another look - you *can* hide the key too. Prefix it with an underscore (which indicates a 'private' key') and it won't show (~line 2530 in `wp-admin/includes/template.php`)
TheDeadMedic
+1  A: 

Additionally, if you prefix your custom fields with and underscore "_" it will be hidden from the custom fields section.

Also, check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.

farinspace