[wp-xmlrpc] Updating Custom Fields Using metaWeblog.editPost

Joseph Scott joseph at josephscott.org
Tue Apr 7 20:04:29 GMT 2009


On Apr 7, 2009, at 12:46 PM, David Weiss wrote:

> Daniel:
>
> "it also leads to the somewhat weird (to me) situation that custom  
> fields can vary wildly across posts, and there is nothing to tie  
> them together except the key names."
>
> I'm not sure what you're saying here.  My understanding of custom  
> fields is that by creating each field, you'll see the option to  
> populate a field with the same name on a per post basis when using  
> the UI.  That makes it easy to use a custom field in a template -  
> you just have to know what the custom field is you want to display.


He's just saying that there's nothing global about a key name.  The  
custom field "country" on post #12 isn't tied to the custom field  
"country" on post #45 other than they happen to have the same name.


>
> It's definitely not "normalized" data - as someone pointed out in  
> another thread, a type-o in creating a custom field will cause some  
> issues for you.  But for the time being, it would seem to me that  
> knowing the field names should pretty much suffice for many users'  
> needs.  A better future solution might be to forget about the  
> meta_id for the custom fields, and do create/update/delete based  
> only on the name of the 'key'. Who really cares what the meta_id is  
> anyway?  For post 'X', if I supply a field named "Y", create it if  
> it doesn't exist, update it if it does.  To "delete" it, provide a  
> null value for it, or do a lookup for it and remove the row from the  
> table.

The reason for this because you can have duplicate keys, so the id is  
required in order to uniquely identify a field.  There's nothing to  
stop you from having 25 custom fields on a post all with the same key  
name.


>
> In my particular situation, doing a "get" on a post to discover the  
> meta_ids only creates more server load and more load on the  
> network.  I have all the data I need in a local database, so being  
> able to create/update/delete a custom field from a post would only  
> take one POST to the server instead of a REQUEST and POST.


See the above, you don't actually have enough information to uniquely  
identify a custom field until you get the id for it.


--
Joseph Scott
joseph at josephscott.org
http://josephscott.org/






More information about the wp-xmlrpc mailing list