Hello, I would like to conditional display custom fields in new post form depending on a selected taxonomy (selected in the same form)
We have categories, and we would like that depending on each category selected at the begining of the post form the have displayed different custom fields
Please advice
Txh
Yes, we checked that doc. Also, we use the conditional display on some of our forms. But this is a different situation. Let me explain to you exactly what are we trying to do.
On our website we are trying to set up a real estate section in which users can post their real estate listings. We created a custom post type Real Estate Listings and created the following taxonomies (CPT categories): Residential, Offices, Industrial, Land. We also created specific custom fields that are used by these categories. The thing is that some fields are good only for some categories. For example, we don't want the "Rooms number" custom field to be displayed on a listing that checked the Land category, because it makes no sense. In the content template, we managed to display only the relevant fields for each category using the conditional display. The problem is when creating an Add New Listing form. In this form we want to use a conditional display so that the user can see only the relevant fields depending on the category(taxonomy) he chooses. So we created an Add New Listing form that starts with a field that lets the user choose his category (taxonomy). Depending on his choice, the form must display only the relevant fields. We managed to do such a thing using Custom Fields but we want to do this conditional display not depending on the custom field but depending on the Category (taxonomy) - so we want to display add new post fields depending on TAXONOMY (not post field).
Can you help us with a solution?
I understand what is your requirement and I understand that you want to display the custom fields based on the taxonomy selection.
Can you please share problem URL and access details and tell me what fields should be displayed with what category?
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I'm on this page and I do not see that the form "Adauga anunturi imobiliare (ID: 50788)" is used there:
=> hidden link
Can you please share where exactly I can see the form.
Also, I would like to know that the taxonomy "Real Estate Categories" is added and available on the form "Adauga anunturi imobiliare (ID: 50788)" - correct?
Hi Minesh, we cleaned the form so it will be easy to explain what we want.
We have a Taxonomy called"real-estate-category" which has 5 options. Depending on the option the user choose on the top of the form , then we would like to have displayed only a specific field as seen in the form now on this page hidden link (we give example for 3 taxonomy values in the form)
Please let me know if you understood what we want.
Thanks
I've adjusted the code within the form as given under:
[cred_show_group if="( $(real-estate-category) eq 'Rezidential (vile, case, apartamente, garsoniere)' )" mode="fade-slide"]
----------------------------------------------------------------------------------
We want the below custom field to be displayed only if the real-estate-category is eq "apartamente-case-vile-garsoniere-de-inchiriat-vanzare"
<div class="form-group">
[cred_field field='tip-imobil-rezidential' force_type='field' class='form-control' output='bootstrap']
</div>
[/cred_show_group]
[cred_show_group if="( $(real-estate-category) eq 'Spatii Comerciale' )" mode="fade-slide"]
----------------------------------------------------------------------------------
We want the below custom field to be displayed only if the real-estate-category is eq "spatii-comerciale-de-vanzare-inchiriat"
<div class="form-group">
[cred_field field='tip-spatiu-comercial' force_type='field' class='form-control' output='bootstrap']
</div>
[/cred_show_group]
[cred_show_group if="( $(real-estate-category) eq 'Terenuri' )" mode="fade-slide"]
----------------------------------------------------------------------------------
We want the below custom field to be displayed only if the real-estate-category is eq "teren-de-vanzare-de-inchiriat"
<div class="form-group">
[cred_field field='tip-teren' force_type='field' class='form-control' output='bootstrap']
</div>
[/cred_show_group]
I can see its working as expected. Can you please confirm.