Search code examples
tumblr

Add unique classes to Tumblr posts using per-post booleans


I know it's possible to create blog-wide meta-if boolean variables in Tumblr themes (e.g. {block:IfNotReversePagination}), but it is it possible to do something similar for individual posts?

For instance: I'd like to be able to create several different widths for Photo posts, and it seems that the easiest way to do that would be to have a checkbox in the Edit screen for a post, labeled Wide Photo or something similar, that I could use to add a class in the theme markup.

Is this possible? If not, is there another way to accomplish something similar?


Solution

  • On a per-post basis you can enter a tag to the post. Say you enter widephoto as a tag on a post you can use the {TagsAsClasses} template tag on your posts to check it.

    <article class="{TagsAsClasses}"></article>
    

    If you don't want the tag showing up in the tag listing for the post you can remove it via JS (though it will still show up in the Tumblr Dashboard).