10 December 2012

Search for multiple labels on Blogger

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 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. Blogger search multiple labels

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.

45 comments:

Unknown said...

nothing working for me :'(

Unknown said...

oh just did Thanks man you are the best !!

Anonymous said...

Works fine without "%20" to designate a space in a label with multiple words.

Unknown said...

thanks or this! :)

Potti Trader said...

yes it is awesome. its 100%working.

WQAINDIA said...

I 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.

Anonymous said...

Could you tell me how this will work in the case of a space in your label eg: 'Lumia 920'

I tried Lumia%20920 but that doesnt work for me

Draven Xarcell Vestatt said...

this 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:

Draven Xarcell Vestatt said...

That should work. Does the label exist?

George B. Moga said...

I 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:

if 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...

Draven Xarcell Vestatt said...

Ok thanks.

Pranav SB said...

Is 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.

George B. Moga said...

As far as I know there isn't, sorry...

Unknown said...

Thanks man!

Anonymous said...

Thanks

aharis said...

Thanks. Works fine on my blog.

Unknown said...

It Doesn't work with max-results=..... !!

George B. Moga said...

Works fine for me! Try http://exde601e.blogspot.como/search/label/Tips+Google?max-results=7. Maybe you didn't use the exact label name?

inforustys said...

Thank you! If works fine :)
And 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 :)

Yabancılara Sağlık Sigortası said...

Thank you very much. It will be usefull.

Nived Kannada said...

For me too...
Not working in my blog Nanogalaxy.org

las tartas de yoya said...

Thanks a lot. It will be usefull.

Ihsan said...

Thanks for tutorial. How t to display the results of the 10 post?

emlakdanismani said...

thanks for this tutorial..but how can we use it with drop down search bar.?

George B. Moga said...

I'm not sure what the drop down search bar is... a search plugin for Blogger perhaps?

Panorama evleri said...

A user is filtering search labels from drop down menus...
Or a list box..

Unknown said...

Hi!

I want to do a searcher that search in both post and labels. anyway to do it??

Thx

George B. Moga said...

Hi,

I haven't done any extensive tests, but it seems to me that the regular Blogger search (from the toolbar on top) does precisely that.

Simple Information Only said...

wwoooww... that's work for me. thanks very much. so it's the parameter...;

{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

:-)

Simple Information Only said...

I'm forgot... LABEL must be indexed.. or created a week ago, if not CAN'T WORK.

Raquel Segal said...

Hello! Tried in my website: http://www.infogeekcorp.com/search/label/Cr%C3%ADticas+Cinema, but it's not showing all the results :(

LiquidShaDow said...

Tried it, it works for mine. Great help there!

Paulo Santos (Administrador) said...

How did you get it working on blogger? I tried on mine, but it doesn't work. :(

iBlogger said...

Nice Tip. It's useful for me. Thanks!

Eric Veal said...

For 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)

FullApkZ said...

Thank you, I will try it.
Hope Work on my Site

Admin said...

http://www.cintaummahmarketing.com/search/?q=label:%22Ubat%20Herba%20Tradisional%22|label:Artikel

Thanks.
it worked for me

Gadget said...

Thanks for information, :)

Unknown said...

Thanks a lot
You solved my problem

. said...

thank you it's fine

Peter Floyd said...

Lovely post

SEO Services said...

This article is very informative and easy to understand. Thank you for sharing!


Prashant B said...

Working. Thanks.

Kome Cafe Vietnamese Coffee said...

Thanks for share!

Working for my blog Kome Cafe

francisco said...

Thanks, I could remove a label using negative sign -

My 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

Post a Comment