Metabox: Query Loop Condition to Show a text when Switch in 'on'

Update!

I think i found the issue - i did change the Field ID from sale? to sale as i thought this could have been the issue with the field. That removed all the toggle states - so actually no toggle was set to “sale” :frowning:

It now is working!


Hello,

i have a CPT setup with Metabos that includes a switch. I want to show a text inside a Query Loop when the switch is on (Metabox database:1). But i fail to do so.

I tried all possible conditions, but none worked. The Text itself does work when i set a false condition (but shows on all Elements.

That is the condition i use:

2023-04-30_09h20_29

If i set it to != = “0” the text is shown, so the database value should not be 0. But == 1 nothing is shown.

Btw: i tried with Metabox Switch and checkbox - same behavior.

I can not figure out why and hope someone can help!

Thanks

Probably won’t work but had a similar issue with acf ages ago, that one ended up working if I checked for true instead of for 1.

Thank you - i tried it all - “true” “checked” “yes” “1” - nothing works :frowning:
What i do not understand is that it does show when i set the condition to != 1 - so i assume there IS something that gets pulled from the DB. I checked the DB table and it is “1” - so all i can think of that it pulls a wrong table or something

Hmm that’s weird. Could it be an issue of true being stored as number one and in the condition it checks against a string of 1 or the other way around? Maybe try adding a text field and see if you enter 1 and check against it if it works.

Just found this one, it’s for acf and a long ass thread but seems similar enough that it might help

I started over and now it works - i think i edited the post type which removed the switch status and i did not notice :frowning:

Although i now have more than one CF with the same name cf_sale and metabox_sale - no clue why they double up.

But i guess me issue is solved - thanks for the help!