Skip Navigation

[Resolved] Looping through checkbox selections in a list

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

Problem:

Setup wpv-conditional shortcode, check the specific option is checked.

Solution:

You can use Types shortcode as condition, for example:

[wpv-conditional if="( '[types field='my-checkboxes' option='0'][/types]' eq 'video' )"]
Here display something
[/wpv-conditional]

Relevant Documentation:

This support ticket is created 3 years, 4 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Julie Tuerk 3 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2153005
Screenshot (17).png

Tell us what you are trying to do? I'm trying to loop through checkbox selections (the checkbox is a custom field). I've followed this documentation but it's not displaying anything.

Is there any documentation that you are following?
https://toolset.com/forums/topic/display-images-from-checkbox-values/
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

Here is the code I'm using. on the content template where I'm putting it, it displays the first two options, but nothing is displayed when I view the single custom post type.

    [wpv-conditional if="( '[types field='reimbursed-services' option='0'][/types]' eq 'video' )"]

  • Virtual visits via video technology
  • [/wpv-conditional]
    [wpv-conditional if="( '[types field='reimbursed-services' option='1'][/types]' eq 'phone' )"]

  • Virtual visits via phone
  • [/wpv-conditional]
    [wpv-conditional if="( '[types field='reimbursed-services' option='2'][/types]' eq 'remote-monitoring' )"]

  • Remote patient monitoring
  • [/wpv-conditional]

This was what I had before I looked up the documentation, but it's only working for the first one, "virtual visits via video technology"
<div class="contact list2">The majority of our health centers are currently reimbursed for:<br>

    [wpv-conditional if="( $(wpcf-reimbursed-services) ne '' )"][wpv-conditional if=" ( ( $(wpcf-reimbursed-services) eq 'video' ) ) " ]

  • Virtual visits via video technology
  • [/wpv-conditional][wpv-conditional if=" ( ( $(wpcf-reimbursed-services) eq 'phone' ) ) " ]

  • Virtual visits via phone
  • [/wpv-conditional][wpv-conditional if="( ($(wpcf-reimbursed-services) eq 'remote-monitoring' ) ) "]

  • Remote patient monitoring
  • [/wpv-conditional][/wpv-conditional][wpv-conditional if="( $(wpcf-vh-contact) eq '' )"]<li class="no-results">None offered at this time[/wpv-conditional]

</div>

What is the link to your site? hidden link password: health

#2153305

Hello,

You are using [wpv-conditional] shortcode in the "Fields and Text" block, to avoid the formatting and escaping character issues, I suggest you try to put those shortcodes into WordPress built-in block "Shortcode Block", and test again:
https://wordpress.org/support/article/shortcode-block/

#2153547

Hi sorry if I wasn't clear. I'm not having formatting issues. The correct output is not being displayed. For example, on the link I shared, hidden link (password: health), if you open the "Virtual Healthcare" tab, the "reimbursements" section should display two bullet items: Virtual visits via video technology and Virtual visits via phone. It is only displaying the first one. I tried to write the shortcode two different ways, as I shared above, but neither of them is working.

#2153653

You can debug the shortcodes easily, for example, output [types field='reimbursed-services' option='1'][/types] directly, check the result in frontend, then use the result in [wpv-conditional] shortcode, if you need more assistance for it, please provide a test site with the same problem, also point out the problem content template URLs, I need to test and debug it in a live website, thanks

#2153925

Thanks, I was able to fix this by taking out the eq 'phone' as it wasn't necessary and was causing nothing to display.

#2153927

My issue is resolved now. Thank you!