Skip Navigation

[Resolved] Add Custom Fields’ descriptions to a form as a shortcode

This thread is resolved. Here is a description of the problem and solution.

Problem:
Add Custom Fields' descriptions to a form as a shortcode

Solution:
There are two ways:
1) You can add a description in the CRED form itself when you create the form.
OR
2) Create a custom shortcocde to pull out the description field value of specific custom field.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/add-custom-fields-descriptions-to-a-form-as-a-shortcode/#post-1076230

Relevant Documentation:

This support ticket is created 6 years, 5 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by troyR-2 6 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1076208

Tell us what you are trying to do? I would like to add Custom Fields' descriptions to a form as a shortcode. Is that easy? Or, is it easier to do add descriptions to the form manually. Currently, I am adding them manually. However, I don't want to make changes in two places.

Is there any documentation that you are following? No.

Is there a similar example that we can see? No.

What is the link to your site? hidden link

#1076230

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - for now this description is intended as a Backend Description. There is no way to display it on frontend form.

There are two ways:
1) You can add a description in the CRED form itself when you create the form.
OR
2) Create a custom shortcocde to pull out the description:

Add following code to your current theme's functions.php file:

function func_display_types_field_desc($atts){ 
	$all_fields=get_option( "wpcf-fields" );
	
	$field = $atts['field'];
	$desc=$all_fields[$field]['description'];
	return $desc; 
}
add_shortcode( 'get_types_field_desc', 'func_display_types_field_desc');

And call in your form as given under:

[get_types_field_desc  field="your-field-name"]
#1076240
solution-issue1.jpg
solution-issue2.jpg
solution-issue-fuctionphp.jpg

That solution does not work. Please see attached images.

#1076253

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Add following code to your current theme's functions.php file:

Add following code to your current theme's functions.php file:
function func_display_types_field_desc($atts){ 
    $all_fields=get_option( "wpcf-fields" );
     
    $field = $atts['field'];
    $desc=$all_fields[$field]['description'];
    return $desc; 
}
add_shortcode( 'get_types_field_desc', 'func_display_types_field_desc');

It should work now.

#1076260

Excellent