Estoy usando una versión modificada de Twenty Twelve e intento mostrar publicaciones recientes de la misma categoría que la publicación actual (excepto la publicación actual) en la barra lateral.
Comencé de esta manera pero algo no está bien:
$category = get_the_category($post->ID);
$current_cat = $category[0]->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;
No soy realmente un programador, así que estoy luchando para entender la lógica, pero me gustaría aprender. Cualquier sugerencia / ayuda muy apreciada!
Gracias, Alex