Excluding One Category From Blog Homepage (WordPress) [en]

[fr] Comment exclure une catégorie de la première page de votre blog WordPress tout en la gardant dans les archives.

The simplest method I’ve found up to now (and I’ve only just found it) if there are certain categories of posts you do not want to see appear on your main blog page, but that you still want to see in the archives, is to use query_posts().

Here’s an example:

This needs to come in right before the while ( have_posts() ) { line. The $query_string parameter means that you can still pass parameters in the URL, so things like special Event Calendar pages will still work.

Careful, though, this only works for one category at a time. You need to use WP_Query for that, and build a separate loop for the homepage.

Similar Posts:

Batch Categories 0.9 [en]

Batch Categories for WordPress has been fixed and enhanced. If you have major category jobs to do, it can probably help you. Feedback and testers welcome.

[fr] Batch Categories pour WordPress a été corrigé et fonctionne à  présent. Le compagnon idéal si vous desirez changer les catégories de nombreux billets en même temps.

Batch Categories 0.9 is out! It’s the ideal companion for large-scale post-import messy category work. List all posts belonging to a category or matching a keyword, and edit their categories, easily visible at a glace with a collection of sexy drop-down lists. What’s new since the the first draft?

  • It now works, and does not “eat” categories without a warning. (Pretty nice of it, huh?)
  • It tells you what it did — which categories it added to which posts, and which ones it removed.
  • Add a whole bunch of posts to a category with one click.
  • Remove a whole bunch of posts from a category with one click.
  • Ensures that all the categories for a post are always listed, whatever the setting for the limit number of drop-down lists.
  • This is what it can look like.

You can still access it as a plugin or edit the Edit navigation menu, as described in my post introducing Batch Categories. If you’re in a hurry, just drop the PHP file into your wp-admin directory and send your browser straight on it.

Next steps?

  • Gather feedback from courageous testers (please don’t blame me if you haven’t backed up your post2cat table and things go wrong) for chasing the last bugs, improving interface and functionality.
  • Redo the code which generates the drop-down lists to take advantage of the category cache, and avoid flooding the database with useless queries.
  • Allow more subtle selection of posts: combinations of categories (AND/OR/NOT), categories without their subcategories…
  • Anything else you would want…?

Update 24.07.04: BB made me notice that “All” and “None” didn’t make much sense in the drop-down which allows one to select the categories to display. Replaced them in v. 0.91 by “Any category”.

Similar Posts:

Life and Trials of a Multilingual Weblog [en]

Here is an explanation of how I set up WordPress to manage my bilingual weblog. I give all the code I used to do it, and announce some of the things I’d like to implement. A “Multilingual blogging” TopicExchange channel is now open.

[fr] J'explique ici quelles sont les modifications que j'ai faites à WordPress pour gérer le bilinguisme de mon weblog -- code php et css à l'appui. Je mentionne également quelques innovations que j'ai en tête pour rendre ce weblog plus sympathique à mes lecteurs monolingues (ce résumé en est une!) Un canal pour le weblogging multilingue a été ouvert sur TopicExchange, et vous y trouverez peut-être d'autres écrits sur le même sujet. Utilisez-le (en envoyant un trackback) si vous écrivez des billets sur le multinguisme dans les weblogs!

My weblog is bilingual, and has been since November 2000. Already then, I knew that I wouldn’t be capable of producing a site which duplicates every entry in two languages.

I think this would defeat the whole idea of weblogging: lowering the “publication barrier”. I feel like writing something, I quickly type it out, press “Publish”, and there we are. Imposing upon myself to translate everything just pushes it back up again. I have seen people try this, but I have never seen somebody keep it up for anything nearing four years (this weblog is turning four on July 13).

This weblog is therefore happily bilingual, as I am — sometimes in English, sometimes in French. This post is about how I have adapted the blogging tools I use to my bilingualism, and more importantly, how I can accommodate my monolingual readers so that they also feel comfortable here.

First thing to note: although weblogging tools are now ready to be used by people speaking a variety of languages (thanks to a process named “localization”), they remain monolingual. Language is determined at weblog-level.

With Movable Type, I used categories to emulate post-level language awareness. This wasn’t satisfying at all: I ended up with to monstrous categories, Français and English, which didn’t help keep rebuild times down.

With WordPress, the solution is far more satisfying: I store the language information as Post Meta, or “custom field”. No more category exploitation for something they shouldn’t be used for.

Before I really got started doing the exciting stuff, I made a quick change to the WordPress admin interface. If I was going to be adding a “language” custom field to each and every post of mine, I didn’t want to be doing it with the (imho) rather clumsy “Custom Fields” form.

In edit.php, just after the categorydiv fieldset, I inserted the following:

<fieldset id="languagediv">
      <legend>< ?php _e('Language') ?></legend>
	  <div><input type="text" name="language" size="7"
                     tabindex="2" value="en" id="language" /></div>

(You’ll probably have to move around your tabindex values so that the tabbing order makes sense to you.)

I also tweaked the wp-admin.css file a bit to keep it looking reasonably pretty, adding the rule below:

#languagediv {
	height: 3.5em;
	width: 5em;

and adding #languagediv everywhere I could see #poststatusdiv, so that they obeyed the same rules.

In this way, I have a small text field to edit to set the language. I pre-set it to “en”, and have just to change it to “fr” if I am writing in French.

We just need to add a little piece of code in the form processing script, post.php, just after the line that says add_meta($post_ID):

 // add language
	$_POST['metakeyselect'] = 'language';
        $_POST['metavalue'] = $_POST['language'];

The first thing I do with this language information is styling posts differently depending on the language. I do this by adding a lang attribute to my post <div>:

<div class="post" lang="<?php $post_language=get_post_custom_values("language"); $the_language=$post_language['0']; print($the_language); ?>">

In the CSS, I add these rules:

div.post:lang(fr) h2.post-title:before {
  content: " [fr] ";
  font-weight: normal;
div.post:lang(en) h2.post-title:before {
  content: " [en] ";
  font-weight: normal;
background-color: #FAECE7;

I also make sure the language of the date matches the language of the post. For this, I added a new function, the_time_lg(), to my-hacks.php. I then use the following code to print the date: <?php the_time_lg($the_language); ?>.

Can more be done? Yes! I know I have readers who are not bilingual in the two languages I use. I know that at times I write a lot in one language and less in another, and my “monolingual” readers can get frustrated about this. During a between-session conversation at BlogTalk, I suddenly had an idea: I would provide an “other language” excerpt for each of my posts.

I’ve been writing excerpts for each of my posts for the last six months now, and it’s not something that raises the publishing barrier for me. Quickly writing a sentence or two about my post in the “other language” is something I can easily do, and it will at least give my readers an indication about what is said in the posts they can’t understand. This is the first post I’m trying this with.

So, as I did for language above, I added another “custom field” to my admin interface (in edit-form.php). Actually, I didn’t stop there. I also added the field for the excerpt to the “simple controls” posting page that I use (set that in Options > Writing), and another field for keywords, which I also store for each post as meta data. Use at your convenience:

<fieldset style="clear:both">
<legend><a href="http://wordpress.org/docs/reference/post/#excerpt"
title="<?php _e('Help with excerpts') ?>"><?php _e('Excerpt') ?></a></legend>
<div><textarea rows="1" cols="40" name="excerpt" tabindex="5" id="excerpt">
<?php echo $excerpt ?></textarea></div>
<fieldset style="clear:both">
<legend><?php _e('Other Language Excerpt') ?></legend>
<div><textarea rows="1" cols="40" name="other-excerpt"
tabindex="6" id="other-excerpt"></textarea></div>
<fieldset style="clear:both">
<legend><?php _e('Keywords') ?></legend>
<div><textarea rows="1" cols="40" name="keywords" tabindex="7" id="keywords">
<?php echo $keywords ?></textarea></div>
<!-- I moved around some tabindex values too -->

I inserted these fields just below the “content” fieldset, and styled the #keywords and #other-excerpt textarea fields in exactly the same way as #excerpt. Practical translation: open wp-admin.css, search for “excerpt”, and modify the rules so that they look like this:

#excerpt, #keywords, #other-excerpt {
	height: 1.8em;
	width: 98%;

instead of simply this:

#excerpt {
	height: 1.8em;
	width: 98%;

I’m sure by now you’re curious about what my posting screen looks like!

To make sure the data in these fields is processed, we need to add the following code to post.php (as we did for the “language” field above):

// add keywords
	$_POST['metakeyselect'] = 'keywords';
        $_POST['metavalue'] = $_POST['keywords'];
   // add other excerpt
	$_POST['metakeyselect'] = 'other-excerpt';
        $_POST['metavalue'] = $_POST['other-excerpt'];

Displaying the “other language excerpt” is done in this simple-but-not-too-elegant way:


    <div class="other-excerpt" lang="<?php print($the_other_language); ?>">
    <?php print($the_other_excerpt); ?>

accompanied by the following CSS:

background-color: #FAECE7;
background-color: #FFF;
div.other-excerpt:before {
  content: " [" attr(lang) "] ";
  font-weight: normal;

Now that we’ve got the basics covered, what else can be done? Well, I’ve got some ideas. Mainly, I’d like visitors to be able to add “en” or “fr” at the end of any url to my weblog, and that would automatically filter out all the content which is not in that language — maybe using the trick Daniel describes? In addition to that, it would also change the language of what I call the “page furniture” — titles, footer, and even (let’s by ambitious) category names. Adding language sensitivity to trackbacks and comments could also be interesting.

A last thing I’ll mention in the multilingual department for this weblog is my styling of outgoing links if they are written in a language which is not my post language, using the hreflang attribute. It’s easy, and you should do it too!

Suw (who has just resumed blogging in Welsh) and I have just set up a “Multilingual blogging” channel on TopicExchange — please trackback it if you write about blogging in more than one language!

Similar Posts:

Batch Category Editing For WordPress [en]

I put together an admin screen for WordPress today which allows changing multiple categories of multiple posts at the same time. Code available, no guarantees.

[fr] J'ai codé une extension à  WordPress qui permet d'éditer les catégories de nombreux billets en un coup. L'écran liste par exemple tous les billets d'une catégorie, accompagnés d'un certain nombre de selects. On effectue les modifications que l'on désire et on soumet le formulaire entier en une fois.

Update 13.07: A more recent version is out!

I had planned to give you a write-up of the beginning of my WordPress experience today. Unfortunately, I decided to clean up my categories somewhat before I did that, and I managed to badly mess things up.

The result is that I spent most of my day writing a Batch Categories admin screen to help me clean things up. It was something I had planned to do, and I suppose it will also be useful to other people.

If you want to play around: copy the code above into a file named batch-categories.php in your wp-admin directory. I highly recommend that you back up your wp_post2cat table before you get going. This script works for me, but hasn’t been tested much, and comes with no guarantees. It is not optimised either, so depending on how many posts and categories you list, the screen can very well take over half a minute to load!

There are still a few functionalities I want to add, in particular: assigning all listed posts to a category in one go (or removing them).

If you want pretty integration with the other screens of the Edit menu, you’ll have to tweak the navigation bar in edit.php, edit-comments.php, and moderation.php.

Update 24.06.04: I’ve uploaded a screenshot of the admin screen so you can see what it could look like.

Update II 24.06.04: Instead of hacking the Edit menu bars, you can also access the Batch Categories screen from the Plugins page: create a file called batch-access.php (e.g.) in your plugins directory. (Beware not to leave any whitespace after the ?>, though, or you’ll get errors. Promised, zips and more detailed documentation will follow.

Update 04.07.04: I tried using the script this morning, and it seems nastily broken (removed all categories for some posts). Use with caution, and get back to me if ever you hack it or modify it, I’m interested! I’ll look into this once I get back home from Vienna.

Update 12.07.04: The script now works as it should! Thanks to Ben and MooKitty for helping me nail the big nasty bug which was driving me bonkers! Two improvements I’m working on right now: making the code more efficient by using the category cache, and adding a “add all listed posts to category X” option.

Similar Posts:

Delicious! A Great Bookmarks Manager [en]

Delicious is an online bookmark manager. It makes it very easy to add and categorize bookmarks, as well as share them with other users. You can also extract your bookmarks from delicious and integrate them in your blog to create a linklog. When I say ‘easy’, I really mean it!

Now, why on earth didn’t I start using delicious ages ago, when I first stumbled upon it? Maybe it didn’t look pretty enough, and didn’t flaunt its features loudly enough for me?

A couple of days ago I paid delicious another visit. See, somebody on #joiito mentioned my Keeping the Flat Clean post, and I suddenly found there was a bunch of people from delicious visiting that article. I thought: “My, people are actually using this thing!” and signed up for an account.

So… what does delicious do? It allows you to easily add pages you visit to your bookmarks, using intelligent bookmarklets (two clicks and no typing to add a link if you want to be minimalist). This is already easier than what I have to do to add links to my LinkBall.

You can categorize your bookmarks very easily by typing words in the “tag” field of the bookmarklet. No need to define categories — delicious takes care of it all for you. You can then view your bookmarks by category or (and this is where it gets interesting) all the bookmarks marked with a same tag. Each bookmark in your list is one-click editable, and each bookmark in somebody else’s list is one-click copyable. For each link, you can also view a list of all the users who have bookmarked it.

Does it stop there? No. All the bookmark lists (by user or by tag) are available in RSS and can be subscribed to within delicious. As a user, you have an Inbox which aggregates the feeds you have subscribed to. You may subscribe to a “user feed” or a “tag (category) feed”. On top of that, bookmark lists are available in plain html, and many users have contributed various hacks which can help you integrate your bookmarks with your weblog. (Update 02.06.04: one thing you shouldn’t do, though, is simply include that HTML feed with a PHP include or an iframe, as this will cause the delicious server to be hit each time somebody views your page.)

If you aren’t a user of delicious yet, you need to go and register right now.

Similar Posts:

Keeping The Flat Clean: Living Space As User Interface [en]

How I applied what I have understood about designing user interfaces to organising my flat so that it too is ‘usable’ and remains clean.

One of my ongoing post-study projects is reorganising my flat from top to bottom, hopefully throwing out half my stuff in the process. I have been thinking a bit about the way I store things.

First of all, I tend to try to minimise waste of space. I will organise things into cupboards and drawers so that they occupy the less space possible. Second, I tend to organise things with taxonomy rather than function in mind. I will try to store objects of the same type together, regardless of their respective frequency of use.

The result is a perpetually messy flat, with whole areas that I never use (places I do not go, cupboards I never open).

I have therefore been rethinking my whole living environment in terms of function and process. What do I use this thing for, and when? How do I deal with common tasks like washing up or doing my mail? And most important, how does clutter arise? An environment where each thing has a place is not sufficient to prevent clutter. If clutter arises, it is not due to “laziness”. It is because the storage system is not usable enough. It was not designed with the user in mind.

I have switched to considering my living space as a user interface rather than as a library of categorised items.

If I catch myself dumping something on the table instead of putting it away, I’ll try to identify what is preventing me from putting it where it belongs. I’ll try to bring this “where it belongs” closer to where I am naturally tempted to put it. (Instead of thinking “ooh I’m a bad girl, I’m not putting things away as I should,” which we all agree does not help in the least.)

Here are a couple of examples of what I have been doing.

First, I identified the main sources of clutter in my flat: dirty kitchen things, clothes, papers and books. Then I tried to analyse how these things ended up lying about my whole flat. I know that I can clean my flat spotless, and that within a couple of weeks it will be messy again. So obviously, there are things I do mechanically which create clutter. Something which breaks the natural “keeping clean” flow.

Let’s take the dirty dishes to start with. (Not the most glamorous example, but I’m sure there are many of you out there who can relate.) Why do I leave cups, glasses, or even plates lying around in various places? A first reason for this, obviously, is that I do not only eat in my kitchen. That’s a fact we will just have to live with. But why don’t I bring things back to the kitchen? Well, more often than not, the kitchen is in such a state that there wouldn’t really be any place to put them. The sink, of course, is already full of dirty dishes. We have here are perfect example of how disorganisation in one area leads to clutter elsewhere.

One factor which helps stuff pile up in my sink (despite my “fool-proof” method for taming dirty dishes) is that I usually have to make space on the drainer before I start washing up. (I’m one of these people who don’t dry dishes but leave them on the drainer to put them away “later”.) And putting the dishes away is a pain because my cupboard is so crammed with stuff that I have to empty half of it before being able to put my plates were they belong. That is where the bottleneck is. Or the limiting factor, if you prefer.

I realised that out of my four kitchen cupboards, there are only two that I regularly open. I proceeded to empty all the junk out of the others and get rid of the most of it (if I never open the cupboards, then I can’t really need what’s inside them, can I?) I then reorganised the things I use on a regular basis in all the available cupboards, focusing on “how easy will it be to put it back there?” rather than “could I use less space for this?”

One significant result concerns plates. (Don’t worry, we’ll soon be done with the kitchen things.) I have big plates and small plates, four of each. I used to keep the small plates piled up on the big ones, which meant that each time I wanted to put a big plate back in the cupboard, I had to lift up all the small plates first (see what I mean?) That didn’t help prevent things from accumulating on the drainer. Now I have the small plates on one shelf, and big ones on another. I use up more storage space, but it’s easier to put things away. I have rearranged all my kitchen cupboards along the same principle, and the kitchen is now much more usable.

This post is getting much longer than what I expected. However, I don’t want to leave you without letting you know what I have come up with for dealing with my incoming mail. I have been using a tray-based system for sorting paperwork for a long time, but it has shown its limitations regularly over the past years. The new system still uses trays, that groups papers according to what I have to do with them instead of what they are. So now, this is what my trays look like; I’ll see as I use it if it needs any modifications:

  • to do (bills to pay, things to investigate or have a closer look at)
  • to do, ASAP (anything urgent)
  • to file, daily business (bank papers, medical papers, salary slips)
  • to file, important (tax stuff and other important things)
  • to look at (optional) before throwing out (various newspapers, information leaflets)
  • to throw out (envelopes and anything else I don’t keep; the bin is often not close at hand)
  • to sort (anything unopened; sometimes I fetch my mail and don’t deal with it straight away

In conclusion, here is my line of conduct:

  1. pay attention to cupboards that are never opened or shelves that are never reached at
  2. keep an eye on what I do automatically and try to adapt the environment
  3. think “actions”, “process”, and “frequency” instead of “categories” and “families”
  4. accept my limitations

The last point is important: there will always be clean washing waiting to be ironed, because no matter how hard I try, I’ll never get around to ironing and putting it away as soon as it’s dry. I therefore need to take this into account and explicitly plan a space for my huge pile of Clothes Waiting To Be Ironed, even if in an ideal world, Clothes Waiting To Be Ironed should not be around.

Similar Posts: