Trying to suppress posts with a specific tag (2)

This is a follow-on to a previous question - I can now get a bit more specific, and I’m hoping someone can suggest something:

When I try to combine wp-if-has-tag="!random" and wp-loop-clear-columns in the same wp-loop with class=“col-xs-12 col-md-4 col-sm-6”, the !has_tag( ‘random’) test doesn’t include what I want it to. I need the tag test to suppress not only the post but also div with the classes and the clear column logic . That is, if the post has the tag “random”, don’t output ANYTHING and don’t add one to the column count.

What I’m looking for is either a way to express my needs in the html, either through attaching the tag test in a different way or by.specifying that the loop excludes posts with the tag “random” (specified by name, not tag-id because that will not be constant). I’ve tried to find a solution in both areas with no success.

The following image shows manually-edited php which does what I want (except that less than 9 posts will show if “random” posts were present - but at least they don’t just leave a gap where they would have been output).


The Pinegrow generated code (the way I’ve currently specified it) looks like this, and leaves a “hole” where a suppressed post would have been:


Any help would be much appreciated. Thanks!

@greyguru sorry for the very late reply, would something like this be of use to you in this situation? it might help simplify your code and allow you to achieve what you’re trying to do.

Thanks Rob,

I haven’t had a chance to look into this in detail yet. For instance, Pinegrow 4 may do things differently. But one thing is for sure, I’m really grateful for you reply because I had a nagging feeling that I had made a change directly to the PHP, and couldn’t find any documentation to myself to tell me where it was. THIS was it! So thanks very much. I’ll update when I take another look, but I’m into so many things it may be another four months! Luckily, this is a cosmetic problem that will only occur when I post a particular kind of post AND it’s in the most recent nine posts.


1 Like

Wow what are the odds of me posting a link to the docs you had previously used, glad it was of some use.