• Nir

    (@nirabrgmailcom)


    Hello There,

    First, great plugin, thanks for that.

    Second, I tried adding (or updating) custom fields using the wordpress function add_post_meta() (or update). For some reason this didn’t work with the plugin and the values did not show right on the post. I noticed that the plugin uses a json format for the custom fields, is the another function I should use, instead of the regular wordpress one ?

    Thanks in advance,

    Nir.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author XYDAC

    (@deepakseth)

    Hey Nir,
    As you have seen i use a different format to store data, The format is as below:
    meta_name : {field_name}
    meta value : array({field_type} => {field_value})
    If you wanna coin a function yourself then you can, Else i’ll write it up sometimes later..:)

    Regards,
    -Xydac

    Thread Starter Nir

    (@nirabrgmailcom)

    can You show and example of using the add_post_meta/update_post_meta with your format ?

    Thanks.

    Plugin Author XYDAC

    (@deepakseth)

    update_post_meta(post->ID,$field_name,array('text'=>$field_value));

    this should work, else i would check it out later when i return. I am traveling right now.

    Regards,
    -Xydac

    Thread Starter Nir

    (@nirabrgmailcom)

    Thanks a lot,

    Two more questions:

    1. what if the key is not ‘text’ ? could that be ?

    2. how do You get the value – please show an example of get_post_meta().

    Again, thanks in advance,

    Nir

    Plugin Author XYDAC

    (@deepakseth)

    Hey,

    1. yes it’s possible that key is not text, it’s different for each field type. look for $name=” in fieldtype/class-fieldtype.php files.

    2.get_post_meta() should work as follow :

    global $post;
    $val = get_post_meta($post->ID, {field_name}, true);
    echo $val[{fieldtype}];

    for example if field type = text, fieldname = username then

    global $post;
    $val = get_post_meta($post->ID, 'username', true);
    echo $val['text'];

    Hope this solves your problem,
    BTW sorry for delay in response.

    Regards,
    -Xydac

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Function to add/update custom field’ is closed to new replies.