Skip Navigation

[Resolved] Update custom postfield programatically

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Luo Yang 7 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#488308

I am trying to update a custom post field through

update_post_meta($postID, 'field-slug', "value");

This doesn't work at all.
Fields I am trying to update are "Select" (I suppose the value should be "1", "2" etc.) and date(actually I don't know which format it needs, currently sending DD.MM.YY format).
What am I doing wrong?

#488386

Now the select field is updating, but I still have problems with teh Date field. Everytime I update it, it sets to January 1st, 1970, whatever the date format I send.
Here's the code I tried to use:
1.

update_post_meta($postID, 'wpcf-shipping_date', date('Y-m-d H:i:s')); 

2.

update_post_meta($postID, 'wpcf-shipping_date', "01.01.2018"); 

3.

update_post_meta($postID, 'wpcf-shipping_date', "2018-01-01"); 

etc.

#488450

Hi

I assume we are talking about a custom date field created with Types plugin, the Types custom date field stores value as time-stamp, you can get the value with PHP function strtotime(). for example:

update_post_meta($postID, 'wpcf-shipping_date', strtotime("2018-01-01"));

More help:
hidden link

The forum ‘Types Community Support’ is closed to new topics and replies.