I am currently writing a custom theme for Tumblr blogs to embed a widget after every post, regardless of their type. This widget requires the post's title, and if there is none, then it takes the blog's title.
According to Tumblr, {Title} refers to the blog title. However, if we have a Text post or a Chat post, {Title} refers to the post title.
Here is my code:
Code:
var title;
if ('{PostType}' === 'text' || '{PostType}' === 'chat')
title = '{Title}';
else if ('{PostType}' === 'photo' || '{PostType}' === 'photoset' || '{PostType}' === 'audio' || '{PostType}' === 'video')
title = '{PlaintextCaption}';
else if ('{PostType}' === 'quote')
title = '{PlaintextQuote}';
else if ('{PostType}' === 'link')
title = '{PlaintextName}';
else if ('{PostType}' === 'answer')
title = '{PlaintextQuestion}';
if (title === '')
title = '{Title}';
If I have a Photo post with no caption for example, then title will be correctly set to the blog title. But if I have a Text post with no title, then title will be set to [empty string] instead of the blog title.
So my question is: how can I get the blog title when I am inside of a Text or Chat post?