Elliott C. Back: Internet & Technology

New Plugin: WP-Asides

Posted in Blogging, My Blog, Plugins by Elliott Back on June 19th, 2006.

This isn’t so much a downloadable plugin as a feature writeup. For a long time I’ve been looking for a good way to do asides in Wordpress, so I decided to start writing a plugin. The way Asides work in Wordpress, you choose a category you want to publish in a seperate column, and then exclude all the posts from that category from the home page. The best way (in 2.xx) to do this is to use the post_where and post_join filters to tack onto the main SQL query, like so:

function ea_where($query) {
    global
$wpdb;
    
    if(
is_home() || is_feed())
        return
$query . ‘ AND category_id != ‘ . get_option(‘ea_category’) . ‘ ‘;
    else
        return
$query;
}

function ea_join($query) {
    global
$wpdb;

    if(is_home() || is_feed())
        return
$query . ” LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) “;
    else
        return
$query;
}

The whole WP-Asides presentation ends up looking something like this:

asides-preview.jpg

Every 5 seconds the old aside fades out (with a little AJAX and scriptaculous) and a new one fades in. You can check out it in action at the top of this blog’s index page.

Now, the reason I’m not releasing this as a Wordpress plugin is that it adds a nice, exclusive feature to my network of blogs, and that it’s pretty easy to make. Call a few wordpress functions, sprinkle in AJAX and scriptaculous effects, design a little CSS and imaging, and you have a cute asides solution!

This entry was posted on Monday, June 19th, 2006 at 11:34 am and is tagged with nbsp nbsp nbsp nbsp nbsp, query function, category id, sql query, writeup, fades, ajax, scriptaculous, wordpress plugin, index page, ea, wp, long time, blogs, blog. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

10 Responses to “New Plugin: WP-Asides”

  1. Tanksfore Nuthin says:

    “The plugin technique is proprietary.”

    Lame.

  2. Elliott Back says:

    The plugin technique is proprietary. However, this bit of code is one you’d insert in a plugin to redirect a given category using the add_filter function and the two filters mentioned in the post.

  3. The King says:

    Can you be little more clear on where to put this in?
    Or your being ambiguous because you don’t want others to have it?

  4. Snykx says:

    Great job, thanks for the ideas! I got the actual ticker working, now I’m making the wp plug in.

  5. Rob says:

    Disappointed that you won’t share the code with everyone since I’ve loved your previous plugins.

    Looks great though.

  6. Thilak says:

    Looks really good. It will surely grab visitors attention. Nice Plugin. Thanks for sharing it with us

  7. Tomme says:

    Hi, your asides look nice, I’m interested in some more details about the functions you have described. I don’t know much PHP yet so its not clear to me exactly what they do and where/how I should call them… any more clues I would be grateful :)

  8. mr nice ash says:

    hi Elloitt, this plugin is really cool. i was trying to follow the way you did it but i cannot succeed. I’m wondering if you can send me the plugin straight. :)

  9. Mark Hutton says:

    Looks very good, nice and neat!

  10. Adrian says:

    You need to fix your link, you spelt Elliott with one T. :)

Leave a Reply

Powered by WP Hashcash