Skip Navigation

[Resolved] Unable to hide post in view using checkbox

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

Problem:

I want to hide some of many posts displayed in a Toolset View.
How can I do this easily, so I do only need to update those Posts I do not want to display (because these are the less in number), instead of updating ALL posts with a Show/No Show value?

Solution:

The easiest is to use a Taxonomy.
Tag the Posts you want to hide with a "no show" tag and leave the Posts you want to show or simply make sure they do not have that tag (which will be the default).

Then create a View and query the posts by Terms "no one of these {your no show term}"

This support ticket is created 4 years 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 replies, has 2 voices.

Last updated by Chris 4 years ago.

Assisted by: Beda.

Author
Posts
#1546829
Screenshot 2020-03-11 at 11.26.56.png
Screenshot 2020-03-11 at 11.26.19.png

I have a view that filters custom posts by distance. I also want to hide some posts so they do not appear and want to do this using a simple checkbox custom field. When I add the checkbox I can limit the display so that those that are checked are the only ones that appear by choosing "equal to the constant 1" but when I change that to "different from the constant 1" no posts at all display. I want to NOT display those that are checked. See screenshots - the settings shown are hiding ALL posts.

What am I getting wrong here?

Many thanks

#1546899

Yes, that's expected

You will only have posts with either 1 saved, or nothing saved, as your checkbox settings state
So querying by nothing (different than one) will return nothing.

It is not suggested to use "save 0" in the checkbox, so that would not be a solution either
The only solution is to query the view by posts where the value is 1
That is the right approach to the solution

#1547117

Ok thank you for the clarification.

Without adding values for every post how can I selectively hide just a few posts - clearly I had it wrong. Is there an easier way to do this? I can use any field type if there is a better way.

Many thanks

#1547227

My issue is resolved now. Thank you.

Decided just to exclude on post id for now. Will suffice the time being.

#1547783

the problem with the Query filter by such a checkbox is, it only offers to filter posts with a value in that field, and then compares that values to anything you set.
It does not allow to filter by non-existing values.

Hence as mentioned the setting "save 0 when not checked", which was intended to solve exactly that issue, giving value to the field you can successfully filter out, by default.
But, this will not help any more, unfortunately: https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

Hence, the only solution with a Custom Field is to actually save values for all posts that you want to display, instead of saving values for posts you do not want to display.

Or, you can use a Taxonomy.
You can create a Term "Not Show", for example, and tag all the posts you do not want to show, with that term
Then, in your View, you can remove all posts with that Tag using a Query Filter for the taxonomy term "no one of these".

Does this help to reach your goal?

#1547793

Changing the status of this ticket. See my last reply above for actual valuable information, this message here can be ignored.

#1547799

Many thanks - that is helpful. I'll use the taxonomy approach if necesary.

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