Skip Navigation

[Resolved] Show custom field based on taxonomy value does not work

This support ticket is created 3 years, 2 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Shane 3 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2207579

I have a taxonomy called Format. In this taxonomy I want to show the input field based on value of taxonomy.

If Text -- show image link
If audio - show audio link
If Vidoe -- show video link.

I am using code but it does not seem to work -

 
<div class="form-group">
		<label for="%%FORM_ID%%_format">[cred_i18n name='format-label']Select Resource Format[/cred_i18n]</label>
      [cred_field field='format' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
	</div>

[cred_show_group if="( $(format) eq 'Text' )" mode="None"]
	<div class="form-group">
		<label for="%%FORM_ID%%__featured_image">[cred_i18n name='_featured_image-label']Add Featured Image[/cred_i18n]</label>
		[cred_field field='_featured_image' output='bootstrap' previewsize='thumbnail']
	</div>
[/cred_show_group]
[cred_show_group if="( $(format) eq 'Audio' )" mode="None"]
	<div class="form-group">
		<label for="%%FORM_ID%%_audio-link">[cred_i18n name='audio-link-label']Audio Link[/cred_i18n]</label>
	  [cred_field field='audio-link' force_type='field' class='form-control' output='bootstrap']
	</div>
[/cred_show_group]
[cred_show_group if="( $(format) eq 'Video' )" mode="None"]
	<div class="form-group">
		<label for="%%FORM_ID%%_video-link">[cred_i18n name='video-link-label']Video Link[/cred_i18n]</label>
	  [cred_field field='video-link' force_type='field' class='form-control' output='bootstrap']
	</div>
[/cred_show_group]

Link - hidden link

#2208005

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

Thank you for getting in touch.

This is actually a known issue and to work around this you will need to use a generic field to house your taxonomies. Then do your conditional based on the generic fields.

The idea is to provide the ID as the value of the generic field and for the title you can just use the taxonomy title.

From there you can hook into the Form when it is submitted to get what value was selected and then use the function below to set the correct term onto the post.
https://developer.wordpress.org/reference/functions/wp_set_post_terms/

Please let me know if this helps or if further clarification is needed.
Thanks,
Shane

#2208199

Thanks, Shane. Is there a timeline for making this fix happen?

#2208263

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

I checked on our internal ticket for this but there isn't any ETA on this one at the moment.

Thanks,
Shane