How to prevent categories from appearing in the WordPress loop

Sometimes, you may want to loop through all the WordPress categories, but excluding some of them.
This is useful if you are organizing your content in categories and keeping some of them as “private”, in order to have more flexibility when rendering them.

This little snippet of code must be copied&pasted in your functions.php file, and it will be called every time you are inside the WordPress loop, thus transparently altering its functionality. Obviously, you have to update the code of the category ID with the one you want: in this example is ID=40.

// No category “40” on the homepage
function preventHomepageTips($query) {
if($query->is_home() && $query->is_main_query()) {
$query->set('cat', '-40'); // 40 is the category ID we want to exclude
}
}
add_action('pre_get_posts', 'preventHomepageTips');

The original author of this snippet is David Walsh. He has also created a little plugin that does just this, be sure to check it out.

No Comments

How to make Angry Birds tutorials

This and this are the two of the greatest game programming tutorials I have ever read.

A must read for any aspiring game programmer.

1 Comment

Think different campaign

This advertising campaign from Apple is always actual, and is still inspiring nowadays.
Think different!

Think different

No Comments

Mouse: R.I.P. 1963-2010

1 Comment

On privacy-risks of location-based networks, again

A few days ago I blogged about location-based services and their privacy risks and implications.

I was not that wrong, apparently, if you read this scary article about what happened to people on Foursquare.

Now I also understand why social networks like Facebook have not yet rolled out location-based features which could kill, in under two seconds, Foursquare, Gowalla & co.: it would be a boomerang for them, so don’t expect features like this to appear soon in the wild.

1 Comment

Interesting application of wisdom-of-the-crowd intelligence

Accordingly to the article linked above, there is actually some collective intelligence in the internet to be gathered from the so-called “wisdom-of-the-crowd”.
Actually, I start thinking: what would happen if there was a better way to tap in real-time into what people are searching on Google? Probably it would be possible to predict stock-market fluctuations, that would not be that hard…

1 Comment

Location-Based Social Networks: Delightful, Dangerous or Somewhere in Between?

Please Rob Me? OK! Says Burglar

Not too long ago, a social experiment called PleaseRobMe launched, displaying the aggregated real-time updates from Foursquare users who used the service’s social sharing feature to broadcast their updates publicly on Twitter. Although that site has since been shuttered, the point they were trying to make still resonates: sharing your physical location with a public network is a dangerous and really dumb idea.

… but people do not seem to get it, and I wonder how many of these cases we will hear in 2010 and following, with the coming of the new wave of location-based social networks.
Figuring how to create a scraper that extracts lots of information from publicly available data is not that hard, after all.

1 Comment

Welcome (back)!

After several years, I finally had some spare time that I could use to re-organize my digital life.

This is just the beginning of a new dawn, but here you can find what I have decided to call “my rantings and ramblings” about technology and stuff I find interesting.

I have preserved most of the stuff that in these years I had on my (old) site: you can find it under this page.

So… I welcome you (back), and have a nice stay!

Marco

No Comments