Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm wondering why WordPress doesn't list PHP array() and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can be edited by user manually.

Edit: Why aren't post meta values displayed if they are stored as a non-string value, meaning, stored as either arrays or a serialized value ?

Example: If a post has a meta key 'custom-meta' with a string value as 'yes', it is displayed in the meta box, but if it has an array value like array('value' => 'yes'), it is not displayed in the meta box.

Can I enable this?

share|improve this question
    
What admin panel are you talking about? Please add a screen hot. –  toscho Oct 19 '12 at 15:53
1  
Custom Fields are available only in 1 place - in post/page editing screen. –  Paul Oct 19 '12 at 16:05
    
I have rephrased the question, hope it's a bit more clear now! –  Rutwick Gangurde Oct 19 '12 at 16:11
    
Thanks for re-writing this with examples :) But I'm still looking for some clarification. Why arrays don't show up? –  Paul Oct 20 '12 at 16:07
add comment

1 Answer

up vote 3 down vote accepted

There is no filter to change that behavior, you would have to replace the entire metabox.

On the other hand: I think there is no really simple way to show and to save those arrays.

Example for a fictive meta key 'foo':

array (
    0 => 2,
    'hello' => array (
        0 => 2,
        'hello' => 'world'
    )
)

Creating a default interface for such an array would be very hard. This metabox is for simple fields, it should be easy to use. And you cannot just present the serialized string: editing that would probably break it. So I think it is a compromise. Better than nothing, but not perfect.

share|improve this answer
    
+1. Presenting a serialized string, which is easily broken, to the typical end-user in the default custom fields metabox is a very bad idea. If you're managing to store arrays as values, then hopefully it won't be too much of a leap to create your own metaboxes to handle the data entry and presentation in a user-friendly way. –  helenhousandi Oct 20 '12 at 16:18
    
Yes, I have my own meta box and it works great but during development I wanted to check its real value and it didn't show up (which made me think my meta box doesn't save data but in fact it does and works great now). For development purposes (when I delete that custom field if value is null/0/nothing/false) it would be great to see this instead of having to login to database. Thanks anyway :) I see why it's done this way. –  Paul Oct 21 '12 at 13:05
add comment

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.