I haven't found a way to detect if user is currently viewing a page, post or an entire list of articles. WordPress has functions like is_page, is_single, etc for that, but does anyone have a way for Tumblr? I'm currently hacking it with the following code:
$(function() {
var uri_root = 'http://' + window.location.hostname + '/';
var uri = window.location.href;
if(uri_root !== uri){
alert("Viewing a single POST or PAGE!");
}
});
I'm wondering if that is the best way of doing this or is there an alternative?
I've found a more adequate solution. According to Tumblr's documentation:
{block:IndexPage} {/block:IndexPage} Rendered on index (post) pages.
{block:PermalinkPage} {/block:PermalinkPage} Rendered on post permalink pages.
So basically, code wrapped in the IndexPage block will run only on pages that can display more then one post whether it's a text, photo, video, etc post.
...and code wrapped in the PermalinkPage will only run for single post permalink pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With