Display all selected checkbox options
-
Hello Greg,
i did some customizations to the list-item and single-ad page.
Now i want to display all selected checkbox options the single pages.
And in the item-list page should be displayed a custom icon to signalize, that there is some information in this ad.But with this code only one option is displayed:
<?php echo esc_html( get_post_meta( get_the_ID(), "custom_field", true ) ) ?>What is the right code for ALL options?
Thank you in advance.
-
This topic was modified 5 years, 2 months ago by
freizeitmonster.
-
This topic was modified 5 years, 2 months ago by
-
Hi,
to list all options use the get_post_meta() with third argument set to false<?php print_r( get_post_meta( get_the_ID(), "custom_field", false ) ) ?>Hi,
thank you very much.
Now it is displayed as “Array ( [0] => Online-Beratung [1] => Online-Vertrag [2] => Hygienekonzept [3] => Lieferung möglich )”.How to remove the “Array ( [0] => “?
And how to display each selected option as one stand alone string? I would like to customize each option with an individual background color?Best
Hi,
there are few ways to do that, if you just want to list them separated by coma you can do it like thisecho esc_html( implode( ", ", get_post_meta( get_the_ID(), "custom_field", false ) ) );-
This reply was modified 5 years, 2 months ago by
Greg Winiarski. Reason: added esc_html() call to prevent potential XSS attack
Hi,
Thank you for your code.I create a custom checkbox field called “custom_corona”.
In this field there are several options to choose.What i try to achieve is this:
https://suchen.mobile.de/auto-inserat/volkswagen-golf-allstar-bmt-klima-shz-pdc-coburg-d%C3%B6rfles/313002435.html?coId=051e7b86-4cf2-48b7-a920-e5f4847280af&action=homeSponsoredProfileRecoAbove the image you can see 5 different colored blocks.
In the item list page (ad card) i want to show a png-image with a tooltip, when this custom field is filled.
Hi,
sorry but this seems more like a general web development question rather than something WPAdverts related?Ok.
Thank you. I will looking for a developer 🙂 -
This reply was modified 5 years, 2 months ago by
The topic ‘Display all selected checkbox options’ is closed to new replies.