[wp-hackers] New Approach to Asides

Mathias Bynens mathibus at gmail.com
Wed Dec 22 19:30:54 UTC 2004

Asides is a great feature, of which I think it should be included in
the default WordPress installation.

However I don't completely agree with the way Matt started (and now
everybody is) handling his short posts --- by filing them under a
special category. I'm convinced categories should reflect the subject,
the content of a post --- not its size. I mean, an Aside can be a post
about everything. Of course, you can tag a post with multiple
categories, but still it's not the same.

Nick [ http://mtdewvirus.com/ ], for example, created his Link It
category lightyears ago. Check his site now; it's full of these short
posts without even a link in them. "Link It"? Right.

The problem is that Asides categories are used as tags, not as categories.

Maybe that's even one of the reasons why there aren't any plans of
implementing something like this in WP, I don't know.

Anyway, I wrote my own Asides script. First, I ran this MySQL query
(mind the table prefix):

ALTER TABLE `wp_posts` ADD `post_type` ENUM('normal', 'short') DEFAULT
'normal' NOT NULL AFTER `post_category`;

Basically, this created a post_type field in the posts table, which is
set to NORMAL on all posts.

Next, I made some PHP-wise changes to the Write/Edit Posts page, in
order to add "[checkbox] This post is a Shorty(tm)". The code I used
for that isn't clean enough to post here. I'm sure you guys can do
this way better.
Anyway, you could manually edit the data in the posts table through phpMyAdmin.

Then, it was just a matter of tagging my short posts, and editing my
index.php template. That part was real easy, as the code is similar to
Matt's [ http://photomatt.net/2004/05/19/asides/ ].

<?php if (('short' == ($post->post_type)) && !$single) { ?>
<ul class="asides">
<li><?php echo wptexturize($post->post_content) . ' '; ?><span><a
href="<?php comments_link(); ?>" title="View the comments on this
post"><?php comments_number('(0)', '(1)', '(%)'); ?></a> <a
href="<?php echo get_permalink(); ?>" title="Permanent Link: <?php
the_title(); ?>">&#182;</a><?php edit_post_link(' (e)');
<?php } else { ?>

Then, of course, throw in Mr Mullenweg's Stupid Hack:

function stupid_hack($str) {
return preg_replace('|</ul>\s*<ul class="asides">|', '', $str);

And we're all set. (By the way, I don't think that hack is stupid ---
it would surprise me if there was a better way to achieve something
like this.)

The reasons I'm posting this on here, and not on my blog, are:
a) the wp-hackers mailing list actually has a readership;
b) I'd love to see Asides get implemented into WP somehow.

You can see all of the above in action on my blog, though there's not
much too see; it looks exactly the same as category-based Asides,
except for a special category to appear in div.meta of course.

P.S.: I am fully aware of the fact that a lightyear measures distance, not time.

Mathias Bynens aka MaThIbUs

More information about the hackers mailing list