Skip Navigation

[Resolved] I'm looking to combine multiple non-types custom fields into one field.

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.49 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 6 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#568114

Tell us what you are trying to do?
I'm looking to combine multiple non-types custom fields into one field. I'd like to follow this example:

add_filter('save_post', 'combine_my_fields');
function combine_my_fields($post_id, $post) {
$address = get_post_meta($post_id, 'wpcf-street', true);
$address = ', ' . get_post_meta($post_id, 'wpcf-city', true);
$address = ', ' . get_post_meta($post_id, 'wpcf-zip', true);
update_post_meta($post_id, 'full-address', $address);
}

however the field I'm working with were not created by Types, but another plugin.

[wpv-post-field name='_VenueAddress']
[wpv-post-field name='_VenueCity']
[wpv-post-field name='_VenueZip']

Could I get an example the proper syntax for one of the lines please? Thanks

Is there any documentation that you are following?
https://toolset.com/forums/topic/combine-custom-fields-into-single-variable/
Is there a similar example that we can see?

What is the link to your site?

#568211

Well, when you get or update Types fields, you need to ensure that you call a Post Meta Slug with wpcf-prefix.

This means you should use slugs like "wpcf-my-field-slug".
For non-Types fields, this is not necessary.

This is Custom code, that is fully built on WordPress Codex, which I suggest you consult:
https://codex.wordpress.org/Function_Reference/update_post_meta
https://developer.wordpress.org/reference/functions/get_post_meta/

Thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.