Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tumblr: How to hide Disqus comments on Pages?

Tags:

css

tumblr

As far as I am aware in Tumblr there is no {block:Pages} block, so anything we add to normal posts is added to pages as well, things like sharing and worst of all, comment systems.

Does anyone know of a hack, or any way to remove/hide elements from pages? It's difficult because pages are using the {block:Permalink} {block:Text} blocks, so I'm pretty stumped.

I recently just discovered how to modify CSS with post tags using just HTML over here: Tumblr: How to control CSS with post tagging (UPDATE: Working Method without JQuery!)

I thought maybe we can use this, the idea would be something like this:

{block:Text}
  <div class="post {block:HasTags}pagefix {block:Tags}{Tag}{/...}">
  ...
{/block:Text}

The way it works is by default we hide any element we don't want to be shown on pages (example: Disqus), adding the class .pagefix between {block:HasTags} in the div wrapper we can tell it to show elements on posts with tags, that way elements will only be shown on posts and not pages, because pages don't have tags.

Two problems with this, 1) all posts MUST be tagged in order to show any hidden items and 2) the Disqus comment script would have to be inserted into every post type, rather than just once before the {/block:Posts} end block.

I may be just placing Disqus in the wrong place, or some other error, let me know what you think, I can't find anything at all about this on the net anywhere. It's so dumb not to have a unique page block...

like image 219
Naota Avatar asked Jun 04 '11 16:06

Naota


People also ask

How do I use Disqus on Tumblr?

Add Disqus To Your Tumblr Alternately, if you're logged into Tumblr, simply browse to Tumblr.com/customize. On the Customize page, select the Appearance tab. Scroll down to the bottom of that list, and paste your Disqus shortname in the Disqus shortname box.

What is Disqus Tumblr?

Disqus is a free commenting system that allows a greater way of communication with fellow blogs on Tumblr. To get started, sign up for an account on Disqus here, once the registration is complete, simply type in the short name you chose into the "Disqus Shortname" text field in theme customisation under theme options.


1 Answers

Simply wrap your Disqus code in the date block.

{block:Date}
    <!-- Disqus code -->
{/block:Date}

Since only posts have dates, the Disqus code will never get rendered on a page. This also solves the problem above where having only one post breaks the method.

like image 116
graygilmore Avatar answered Sep 22 '22 12:09

graygilmore