Your sites Log in Sign up Menu

Exclude posts with specific tags?

Would it be possible to show all entries excluding posts with a specific tag?


3 months ago, 7 replies   developers   Improve this question

Absolutely! You will first want to fork an editable version of your template if you haven't already.

You will notice that lists of blog posts are rendered in your template's entries.html file and archives.html file, among other template files. These lists look something like:

{{#entries}}
   ... <a href="{{{url}}}">{{title}}</a>
{{/entries}}

To filter posts with the specific tag Apple out of these lists, you can use an inverted section, which looks like this:

{{^tagged.apple}}
...
{{/tagged.apple}}

The full example, using an inverted section to remove posts tagged Apple from your list of entries will look something like this:

{{#entries}}
{{^tagged.apple}}
   ... <a href="{{{url}}}">{{title}}</a>
{{/tagged.apple}}
{{/entries}}

Please let me know if you have any questions about implementing this! I'm always willing to answer over email if you have something you'd rather not share publicly, too.

Answered 3 years ago · Improve this answer

Apologies for replying to a 2 year old post.

I'm trying to achieve this with the Photo template, where I'd like to not display posts tagged "Blog" on the main page. Adding the above code to the grid_bookshelf.html page (which is where the {{entries}} blog lives in this template) doesn't hide the posts, and causes some weird display issues with the posts I don't want hidden.

Is there another method to achieve this effect, or maybe something I'm missing/not understanding about the way the Photo template builds the main page?

Thanks for any help you can give me!

Answered 9 months ago · Improve this answer

If you're using the bookshelf grid on the Photo template and you'd like to remove posts tagged 'Apple', you'd insert a new line with the following below line 137:

{{^tagged.apple}}

And a new line with the following below line 179:

{{/tagged.apple}}

Does that make sense? Please let me know if you have any questions

Answered 9 months ago · Improve this answer

Hello! Quick follow-up question. I successfully excluded posts with a specific tag from my entries.html page (using a modified version of the Blog template). However, it seems like the hidden posts still count toward the "Posts per page" limit, so if there's a bunch of hidden posts, there can be situations where only 1 'real' post appears.

Is there a way to prevent this behavior so the counter for "Posts per page" only counts visible posts? It's also entirely possible I'm missing something here in my approach.

Thanks!

Answered 7 months ago · Improve this answer

It's not possible right now but this is something I plan to make possible – if you want me to email you when it's ready please contact us

Answered 7 months ago · Improve this answer

Is there an update to this? I have the same problem in that from a specific number of "excluded" tagged posts onward the untagged, "normal" content on the front page disappears and is pushed to the next page(s).

I am not sure where the counting takes place (I assume somewhere in the JS), but couldn't specific tags not be sent to the compile engine to be excluded from counting?

Answered 4 months ago · Improve this answer

The problem is that the filtering happens after the pagination. I need to build a more complex query into the back end. If you would like to be notified when this is added via email, please contact us

Answered 3 months ago · Improve this answer