Sorry, I've been reading http://codex.wordpress.org/Template_Tags/query_posts and trying to work out how to pass a variable I want into the query post, but not been getting very far with it.
In plain english I'm wanting wordpress to produce a list, in the sidebar, of the 5 most recent posts from category 'x' if the single post someone is looking at is in category 'x'
The code I came up with that is wrong looks like this:
<?php $category = get_the_category(); $class=$category->cat_name; ?><?php $temp_query = clone($wp_query); ?> <?php query_posts('cat=' . $class. '&showposts=5'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li> <?php endwhile; endif; ?> <?php $wp_query = clone($temp_query); ?>
It's returning the 5 most recent posts of the site.
Any help would be greatly appreciated!!