I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar.
I started this way but something's not ok:
$category = get_the_category($post->ID); $current_cat = $category->cat_name; //This will get me the first category assigned to the current post but since every post has only ONE cat. assigned to, it's good enough //Next, in my sidebar widget I have this: $my_query = new WP_Query('category_name='.$current_cat.'&showposts=10'); while ($my_query->have_posts()) : $my_query->the_post(); ...display my titles here ... unset($current_cat); //I'm not sure I need to unset this variable? endwhile;
I'm not really a programmer so I'm struggling with understanding the logic but I'd like to learn. Any suggestions/help much appreciated!
Thank you, Alex