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.
- by category
- by tag
- have “asides” show up in categories or not
- Remove a category from the loop (or include it).
- any other features?
Popularity: 29% [?]
on Sep 28th, 2007 at 11:33 am
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?
on Sep 28th, 2007 at 12:06 pm
@ZMAng - are you using WP 2.3? I’m using it on this blog and the exact same code…
on Sep 28th, 2007 at 2:02 pm
I really like what you have here. I think I’ll be adding your blog to my blog roll.
J
on Sep 28th, 2007 at 4:30 pm
Yeap, I am. Hmm, that’s weird. Thanks though.
on Sep 28th, 2007 at 7:35 pm
@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?
on Nov 3rd, 2007 at 2:29 pm
[...] 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 [...]