Home » Featured, WordPress Tips

How to Create Asides in WordPress 2.3 or up

26 September 2007 1,051 views 6 Comments

A few themes I’ve been testing out have been failing when it comes to creating asides in the sidebar.

I wanted to put my asides in the sidebar in WordPress 2.3 and started doing some snooping through the new database structure… mainly the two tables wp_terms and wp_term_taxonomy.

You can copy and paste the following code into your sidebar (above or below the if widgetized fuction).

<li><h2>Asides</h2>
<ul>
<?php
$tagid = $wpdb->get_var("SELECT term_id FROM wp_terms WHERE slug = 'asides'");
$get_asides = new WP_Query('cat=' .$tagid. '&showposts=5&orderby=post_date&order=desc');
while ($get_asides->have_posts()) : $get_asides->the_post();
$do_not_duplicate = $post->ID; ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</li>

The previous code basically extracts the numbered id from the category named “asides”, puts that id number into a loop that only includes 1 category (by id)… then displays just the title of that “Aside”.

I will be writing a small widgetized plugin for this when I get home this afternoon. The plans for the plugin are to offer a few options for customizing the way asides are shown.


1 Star2 Stars3 Stars4 Stars5 Stars
(No Ratings Yet)
Loading ... Loading ...

6 Comments »

  • ZMAng said:

    Hi. Great post mate. Just wanted to ask how you’ll be getting the asides to work with tags. The “cat” parameter doesn’t seem to work with tags. Is it just me?

  • Mark Penix (author) said:

    @ZMAng - are you using WP 2.3? I’m using it on this blog and the exact same code…

  • J-Mill said:

    I really like what you have here. I think I’ll be adding your blog to my blog roll.
    J

  • ZMAng said:

    Yeap, I am. Hmm, that’s weird. Thanks though.

  • Mark Penix (author) said:

    @ZMAng, I missed what you were saying last time… Tags is a little bit different than WP categories… I’m looking into it and I’ll email you when I find out how to do it.

    @jmill, glad you like it! I appreciate the link as well… anything you’d like to see around here?

  • Actualizado a Wordpress 2.3.1 : EREBE said:

    [...] habilitar los asides esta vez utilicé el hack descrito en Creating Asides in Wordpress 2.3 que funciona a la perfección, junto con una modificación en el loop para evitar que aparezca el [...]

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.