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?
Each post has a div of class post. So, count the number of div’s with post classes.
Something like this:
$('div.post').lengthordocument.getElementsByClassName('post')if there is no jQuery.