Skip Navigation

[Resolved] get all custom fields

This support ticket is created 3 years, 11 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.

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: Africa/Casablanca (GMT+01:00)

This topic contains 6 replies, has 3 voices.

Last updated by Jamal 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1887997

Hi, there is an elegant way to collect all data from all available Toolset custom fields of a certain CPT?

#1889393

This issue is now escalated to the developers. I'll keep you informed as soon as we have a fix or a workaround.

#1899685

Hi, any news on this matter?
I have a website in stand-by waiting for this solution 🙁
Thanks

#1901363

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Jamal is off today. We don't have a solution from the developers yet, but I crafted a workaround you can use or adapt as required.

The following registers a shortcode 'checkboxes' that will (correctly) output the checked option titles for the current post:

add_shortcode( 'checkboxes', function( $atts = [] ){

	// provide defaults
	$atts = shortcode_atts( 
		array(
			'field'=> 'null',
			'separator' => ', '
		), 
		$atts 
	);

	$output = "";
	global $post;	
	
	$field_settings = types_get_field( $atts['field'] );

	$field_values = get_post_meta( $post->ID, 'wpcf-'.$atts['field'], false );
	$field_value_options = array_keys( $field_values[0] );
		
	$separator = "";
	foreach ($field_value_options as $field_value_option) {
		
		$field_value_option_title = $field_settings['data']['options'][$field_value_option]['title'];
		$output .= $separator . $field_value_option_title;

		$separator = $atts['separator'];
	}	

	return $output;
});

You need to pass the checkboxes field slug, and can optionally pass a separator string (which otherwise defaults to ", "), like so:

[checkboxes field='checkers' separator='|']
#1902061

Hello,

Can you check if the provided custom code helps you get the labels of the checkboxes field?

I'll let you know as soon as we have a fix from the developers.

Thank you.

#1904843

Hi,
first of all, thanks for the custom code, I really appreciate that.
As the site is almost finished and working, I am trying to adapt it to the function I have already in place.

Still hoping the bug will be corrected in the next update.

Thanks

#1906183

Thank you,

We'll keep you updated as soon as we have a fix or a patch for this issue. As of now, there is nothing we can do further, so I suggest that we mark this ticket as resolved. Feel free to open a new ticket or chat for any other request or question.

Best regards,
Jamal