Using the condition statements in Blogger, I'm trying to add a script to a specific URL. I have never been able to get this to work, and I have been putting it off until now.
At this site, it says to use: <b:if cond='data:blog.url == "PUT_URL_HERE"'>
So that's what I tried:
<b:if cond='data:blog.url == "http://xarpixels.blogspot.com/search/blog"'>
<script>
$( document ).ready(function() {
var $content = $('#main');
$content.imagesLoaded( function(){
$content.masonry({
itemSelector : '.post';
});
});
});
</script>
</b:if>
Although, it isn't working. When I view the source, that script is not loading. What am I doing wrong?
You can match the label name using the below condition
<b:if cond='data:blog.searchLabel == "Label Name">
this will come up only on the label pages of 'Label Name'
</b:if>
When you make conditions to match URLs, never use data:blog.url
but use data:blog.canonicalUrl
instead or else you will end up having different code being rendered across different countries.
<b:if cond='data:blog.canonicalUrl == "http://blog.blogspot.com/2013/05/post.html"'>
Text or code that will be displayed only on specific url
</b:if>
Reference : http://www.bloggerplugins.org/2012/02/country-specific-blogspot-urls.html
Copy paste this exact code and it will work
<b:if cond='data:blog.url == "http://xarpixels.blogspot.com/2013/04/test-post.html"'>
Text or code that will be displayed only on specific url
</b:if>
When you open ur blog in India,it redirects to blogspot.in......perhaps u were including .in (or some other country code)instead of .com
That data:blog.url
will contain query string too, so that Data Tag is not that useful in your case.
I'm not aware of Blogger Data Tag that would return URL without query strings. You could try to replace that blogger conditional statement with a javascript.
Something like this:
if (window.location.href.split('?')[0]=='http://xarpixels.blogspot.com/search/blog')
{
...
}
Also I'm not sure your search URL is correct. On my Blogger site I have it like this:
http://mybloggersite.blogspot.com/search?q=
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