Labels for posts and displaying pages containing only articles with a specific label are pretty basic features for any blogging platform. But what if you want to search for several labels and retrieve articles that contain all those labels or any label? Is that even possible? I asked myself this at some point and a comment from yesterday prompted me to finally find the answer.
One of the solutions I discovered on the Blogger help forums uses search with a query in this format: <blog-URL>/search/?q=label:LABEL1+label:LABEL2. This returns posts with both labels. I tested it myself and it works, but it’s hard to manually build the URL and the search is case sensitive, meaning that it will return no results it you don’t input the label name exactly as created in Blogger.
While playing around on the blog I discovered an easier way to do this: modify the normal label URL in Blogger by adding a + sign followed by the name of the second label: <blog-URL>search/label/LABEL1+LABEL2. It’s easier to remember and to type, but it’s also case sensitive. It actually works with more than two labels – I only tested it with three, so I’m not sure if there is a limit to the number of labels you can add in the URL. I don’t use any labels with multiple words so I couldn’t test this case, but it’s safe to assume you need to escape spaces by replacing them with %20 just like Blogger does with the regular label pages.
But what about the other case, when you want to find posts with any of those labels – the OR operator instead of AND? Unfortunately the second option doesn’t seem to support OR, but the first one does: just replace the + in the search query with a vertical bar like this: <blog-URL>/search/?q=label:LABEL1|label:LABEL2. It’s fun to see this in action especially with labels that have very little to do with one another.
nothing working for me :'(
ReplyDeleteFor me too...
DeleteNot working in my blog Nanogalaxy.org
oh just did Thanks man you are the best !!
ReplyDeleteWorks fine without "%20" to designate a space in a label with multiple words.
ReplyDeletethanks or this! :)
ReplyDeleteyes it is awesome. its 100%working.
ReplyDeleteI had to search so many authors to learn blogger template and its complexities. But now my journey has ended as I have reached an excellent author to learn anything in Blogger. I will be commenting here of and on and seeking guidance to move forward.
ReplyDeleteCould you tell me how this will work in the case of a space in your label eg: 'Lumia 920'
ReplyDeleteI tried Lumia%20920 but that doesnt work for me
That should work. Does the label exist?
Deletethis works well, but I also wish to add something to the page via a condition. I cannot get the condition to work. Do you know how? This is what I tried:
ReplyDeleteI think the condition got stripped from the comment, but I found your question on StackOverflow. I'm not sure if Blogger supports on OR operator, so you should probably try to nest the conditions, something like:
Deleteif cond='data:blog.searchLabel == Graphics' [code]
else if cond='data:blog.searchLabel == Identity' [same code]
else if cond='data:blog.searchLabel == Brand' [same code again]
else [the other option]
Not very efficient, but unfortunately I don't see another solution...
Ok thanks.
DeleteIs there any way in searching inside a specific label. So i have a label named label 1, i need to search articles only inside the label 1 and no other articles from any other labels should come.
ReplyDeleteAs far as I know there isn't, sorry...
DeleteThanks man!
ReplyDeleteThanks
ReplyDeleteThanks. Works fine on my blog.
ReplyDeleteIt Doesn't work with max-results=..... !!
ReplyDeleteWorks fine for me! Try http://exde601e.blogspot.como/search/label/Tips+Google?max-results=7. Maybe you didn't use the exact label name?
DeleteThank you! If works fine :)
ReplyDeleteAnd you can use this method to divide your posts in categories. I´ve created a new link-tipe page whose url link is a search with two labels.
Now, in my pages widget I have my blog posts divided properly :)
In:
http://inforusty.blogspot.com.es/
One of the pages is:
http://inforusty.blogspot.com.es/search/?q=label:me.sobra||label:me.falta
So thank you again :)
How did you get it working on blogger? I tried on mine, but it doesn't work. :(
Deletethank you it's fine
DeleteThank you very much. It will be usefull.
ReplyDeleteThe best and easiest way to search through labels is to add a menu bar on your home page. Just put the categories in the drop down menu and add the links through your labels. This will make refine and easy to track your blog posts under each label. Just check here And you will see how it works for me
ReplyDeleteThanks a lot. It will be usefull.
ReplyDeleteThanks for tutorial. How t to display the results of the 10 post?
ReplyDeletethanks for this tutorial..but how can we use it with drop down search bar.?
ReplyDeleteI'm not sure what the drop down search bar is... a search plugin for Blogger perhaps?
DeleteA user is filtering search labels from drop down menus...
ReplyDeleteOr a list box..
Hi!
ReplyDeleteI want to do a searcher that search in both post and labels. anyway to do it??
Thx
Hi,
DeleteI haven't done any extensive tests, but it seems to me that the regular Blogger search (from the toolbar on top) does precisely that.
wwoooww... that's work for me. thanks very much. so it's the parameter...;
ReplyDelete{your blogspot address}/search/?q=label:LABEL1+label:LABEL2 >>> show ONLY label 1 "with" label 2
{your blogspot address}/search/?q=label:LABEL1|label:LABEL2 >>> show ALL thread have Label 1 "and or" label 2
:-)
I'm forgot... LABEL must be indexed.. or created a week ago, if not CAN'T WORK.
DeleteHello! Tried in my website: http://www.infogeekcorp.com/search/label/Cr%C3%ADticas+Cinema, but it's not showing all the results :(
ReplyDeleteTried it, it works for mine. Great help there!
ReplyDeleteNice Tip. It's useful for me. Thanks!
ReplyDeleteFor labels with spaces in OR (|) searches, use quotes to surround the label value! For example: http://frenchdipreviews.blogspot.com/search/?q=label:%224%20of%205%22|label:%223%20of%205%22 (the %22 character is a double quote)
ReplyDeletehttp://www.cintaummahmarketing.com/search/?q=label:%22Ubat%20Herba%20Tradisional%22|label:Artikel
DeleteThanks.
it worked for me
Thank you, I will try it.
ReplyDeleteHope Work on my Site
Thanks for information, :)
ReplyDeleteThanks a lot
ReplyDeleteYou solved my problem
Lovely post
ReplyDeleteThis article is very informative and easy to understand. Thank you for sharing!
ReplyDeleteWorking. Thanks.
ReplyDeleteThanks for share!
ReplyDeleteWorking for my blog Kome Cafe
Thanks, I could remove a label using negative sign -
ReplyDeleteMy tests:
/search/?q=label:Wave show all Waves
/search/?q=label:Wave%20-label:Social show all Waves except who has Social too
/search/?q=label:Wave|label:Social show all Waves and all Socials but it does not show who has both
/search/?q=label:Wave+label:Social show only Waves that has Socials too