Photo: Jason Mrachina (CC BY-NC-ND 2.0) |
Blogger is a database that lets you shuffle and filter posts in different ways.
Today we take that to the next level, with logical OR searches on labels A or B (posts with any of the labels).
This is a sequel to the simpler logical AND search: only posts with both labels A and B.
Label Search OR
myblog.blogspot.com/search/?q=label:label1|label:label2
(You can use more than two search terms.)
Note that syntax: q=, then label:, then the label name, separated from the next by the | character.
In this case, | means "or."
That is the "pipe" or vertical bar. On many Western keyboards it is the uppercase right-leaning slash (\).
If you have trouble finding it, you can use its hexadecimal code instead: %7C.
It might look garbled (/?q=label:label1%7Clabel:label2
) but will work in your browser bar.
Although the AND search I described previously is a label-search page that uses the "/search/label/" form, this OR search is a general search, though one restricted to labels.
Here is OR in action:
too-clever-by-half.blogspot.com/search/?q=label:feeds|label:"things that
changed"
That's all posts with either label (or both).
Image: Kismalac (public domain) |
A OR B |
Defined as any posts about feeds or things that changed, or both, together on one page.
Oh yeah. Those quotation marks:
If any of the search terms comprises more than one word, you'll have to put those terms in quotes.
label:"things that changed"
Pretty fussy work, but the point is that once you have constructed the url correctly (and you should test it), it's an accessible page on your blog.
You can link to it, and your readers can view the page with a single click. The page will revise itself whenever you apply or remove any of the labels involved.
That's the power of databases!
Order
/search/q=label:
" method is a true search, so if you want to
link to the search ordered by date, add this to the url:
&by-date=true
The default alternative is an undefined "by relevance" sort, if you are curious to know what Google thinks is "relevant."
Extra Credit
- You can use these methods on more than two labels at a time.
-
The "
?q=label:
" syntax also works with the "+" operator for logical AND. It's just a bit fussier than the alternative syntax. -
Without the "
label:
" qualifier, a search term finds posts that contain the word rather than the label. So, you could search for all "things that changed" posts that include the word "Picasaweb." (A word search, without the "label:
" qualifier, does not search label names.) - If you are a Boolean hotshot, you can construct links like "all posts that have the 'attitude' label and at at least one of 'tips' or 'things that changed.'"
- Update: It is also possible to exclude posts from a database search using logical not. "All posts about bread that are not also about cheese."
Adam, I'd love to tidy a set of labels on my blog but am scared as I have 427 posts. Any cautious hints before I jump in?
ReplyDelete@standby, this is really a strategic editorial decision, rather than a technical one. What sort of user experience can you facilitate by characterizing posts by topic?
DeletePut yourself in your readers' place: how can you organize posts to make it easier to go deeper into the blog and find interesting things?
Forethought like this is a good idea. However, fear should not hold you back since you can undo anything you do with labels.
The blog linked to your account only has 12 posts, so I am guessing you have another account. Since I can't see the other blog, these remarks are kind of generic.
But, I hope, helpful.
Sorry to take so long in saying THANK YOU. I hadn't realised my experimental blog was visible - now corrected. Yes, it's a much bigger blog that I'm referring to. Your assurance helps. Thanks again
ReplyDeleteI just knew about the + operator working for labels but didn't know about the remaining. This could be very useful in creating a more useful set of options for the visitors. Many thanks to you sir! 🙏
ReplyDelete