Blogger URL Status Statements

Using the conditions in Blogger, I am trying to add a script to a specific URL. I could never get this to work, and I have put it off until now.

This site says: <b:if cond='data:blog.url == "PUT_URL_HERE"'>

So 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 does not work. When I look at the source, the script does not load. What am I doing wrong?

+4
source share
3 answers

You can match the label name using the condition below

 <b:if cond='data:blog.searchLabel == "Label Name"> this will come up only on the label pages of 'Label Name' </b:if> 

When you create conditions for matching URLs, never use data:blog.url , but use data:blog.canonicalUrl instead, otherwise you will get a different code that will be displayed in 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> 

Link: http://www.bloggerplugins.org/2012/02/country-specific-blogspot-urls.html

+9
source

Copy 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 ...... maybe you included .in (or some other country code) instead of .com

+2
source

That data:blog.url will also contain a query string, so the data tag is not so useful in your case.

I don’t know a Blogger data tag that will return a URL without query strings. You can try replacing this conditional blogger statement with javascript.

Something like that:

  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, it looks like this:

 http://mybloggersite.blogspot.com/search?q= 
+2
source

Source: https://habr.com/ru/post/1481220/


All Articles