Custom Fields
Re-Envisioned
Support Meta Box Builder Default field is not working

This topic contains 5 replies, has 2 voices, and was last updated by  Anh Tran 2 years, 10 months ago.

  • Creator
    Topic
  • #4179
    Resolved
    piretrus
    Participant

    `The default value is not working. When the metaboxes charge in the post, the value of the fields with default value are blank, don’t return anything, until write or select something.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #4188

    piretrus
    Participant

    If the post is new, all the default values loads correctly, but if is old not.

    #4189

    piretrus
    Participant
    #4218

    Anh Tran
    Keymaster

    For old posts, the custom fields already have some value (even empty values). So it doesn’t make any sense to set the default value anymore.

    #4245

    piretrus
    Participant

    It’s possible force to recover the default values from metabox?

    We have 5 metabox configurations, and by default witch type of post have a metabox. The idea is that all the custom psot type with name XX have the same default values from his metabox.

    It will be possible to force that and old post come back to the defaults values?

    #4260

    Anh Tran
    Keymaster

    If you just want to revert the default value for the old post, you can just run this code:

    $post_id = 123; // Your post ID
    $field_id = 'abc'; // The field ID
    $default = 'some thing'; // Default value
    update_post_meta( $post_id, $field_id, $default );

    Put it in a functionality plugin and run it once.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.