Nibbles – Multiple Column Hack for WordPress 1.2.2

Nibbles allows multiple columns to appear on the front page of WordPress 1.2.2. Each column contains the most recent posts in the category definition you specify. On Magic Bean Dip, my main column is selected by this line of code: $cat=-7. The minus sign indicates that every post that is not in category 7 should be displayed. The posts in my side blog are selected by the opposite: $cat=7. It should be easy to modify the hack to create more than 2 columns on your front page, all of which reside in the same WordPress database.

If Once is Good, Twice is Better

Nibbles works by calling the main WordPress routines in wp-blog-header.php once for each column. It’s very simple and the actual meat of the hack is about 10 lines of code, the rest is documentation and formatting the posts.

It’s a Hack Because It Does Things It’s Not Supposed To

wp-blog-header.php was not written to be called more than once, so Nibbles unsets many of the variables created in the first pass of wp-blog-header.php before calling it again. That fools WordPress into filling the $posts array second time. After that, it’s simply a matter of doing another foreach loop to display the second set of posts.

Download Nibbles v0.1 and follow the instructions to paste the code into your index.php file.

Comments are closed.