问题
I tried different codes from different themes and google search. Though everything just shows a notification only if there are notes in a post.
So when there aren't notes, i wanted to show "0 notes" - How can I do that
Thanks
回答1:
From the first look solution seems to be impossible to output anything if Post has no notes due to tumblr custom themes docs, but as we shall see, the impossible is possible.
I invented trick to help you with your question.
The main idea of trick is to create special css class
only if post has no notes, after it trick is using content of pseudo-elements to insert necessary text in .notes
block of post.
Trick requirements: only tumblr markup and css;
Tumblr markup:
{block:Text}
<article class="{block:PostNotes}no{/block:PostNotes}nonotes">
…
<div class="notes">
{block:PostNotes}
{PostNotes}
{/block:PostNotes}
</div>
</article>
{/block:Text}
One line css:
article .nonotes .notes:before { content: '0 notes'; }
回答2:
I'm having the same problem. Starting to think there's no way around this :( except maybe to write your own script to get the NoteCount using the Tumblr API. Hopefully someone will be able to answer this!
来源:https://stackoverflow.com/questions/7760446/how-can-i-show-0-notes-in-tumblr-when-there-arent-any-notes