Skip Navigation

[Résolu] Use Checkbox to display custom fields on other CPT's

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to check parent post checkbox value and display content conditionally.

Solution:
Using [wpv-conditional] shortcode we can dispaly conditional output. To check parent post custom field value using types shortcode you should add "id" attribute to types shortcode.

For example:

[types field='presbyter-section-1' id='$ministers'][/types]

Where:
"ministers' is a parent post slug.

To check field value we will use [wpv-conditional] shortcode:

For example:

[wpv-conditional if="( '[types field='presbyter-section-1' id='$ministers'][/types]' eq '1' )"]

Condition is True                    

[/wpv-conditional]

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created Il y a 8 années et 1 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Auteur
Publications
#374515
displays-correct.png
checkbox-settings.png
pastor-fields.png

Hi Minesh,

I have a Custom Post Type called Pastors. I want to be able to click on a checkbox in the Pastor Fields to assign a designation of authority (see screenshot pastor-fields).

I can do this on the actual Pastor Pages by using the below code on a Pastor Template assigned to the Pastor Custom Post Type. So when I check Presbyter Section 1 checkbox the content inside the conditional will display on a Pastor CPT page. All good. (see displays correct)

 [wpv-conditional if="( $(wpcf-presbyter-section-1) eq '1' )"]          
          [types field="pastor-first-name"][/types] [types field="pastor-last-name"][/types]  <br>
          Presbyter Section 1
          [/wpv-conditional]

          [wpv-conditional if="( $(wpcf-presbyter-section-2) eq '2' )"] 
       [types field="pastor-first-name"][/types] [types field="pastor-last-name"][/types]   <br>   
         Presbyter Section 2
          [/wpv-conditional]

          [wpv-conditional if="( $(wpcf-presbyter-section-3) eq '3' )"]
       [types field="pastor-first-name"][/types] [types field="pastor-last-name"][/types]   <br>            
          	Presbyter Section 3
          [/wpv-conditional]

Now I want to have this ability to display the pastors that are checked on other Custom Post Type pages (like churches, Ministries, Sections) and on normal WP pages.

I've spent 2 days trying to figure this out and would welcome your help with this. Please let me know if I can provide anymore information to help you.

Ronald E

#374527

Minesh
Supporter

Languages: Anglais (English )

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

Hello. Thank you for contacting the Toolset support.

Now I want to have this ability to display the pastors that are checked on other Custom Post Type pages (like churches, Ministries, Sections) and on normal WP pages.
=> You mean to say you want this on admin section pages?

if no, could you please send me problem URL where I can see your issue and where you want to display same code?

*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#375033

Minesh
Supporter

Languages: Anglais (English )

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

Could you please check now.

You just did one mistake that you have prefix "wpcf-" before the field name. Please not that when you use Types shortcode, you just need to enter field name without "wpcf-" prefix :).

For example:

[types field='presbyter-section-2' id='$ministers'][/types]
[types field="phone"][/types]

Have a great weekend!!

#375039

Thank you, that little bit of info will enable me to go very far with this project.

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