I use this code in shortcode for show posts :

while ($wp_query->have_posts()) : $wp_query->the_post(); 

$imagen = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "medium");
$ruta_imagen = $imagen[0];
if ($ruta_imagen!="")
$ruta_img="<a href='".get_permalink($post->ID)."'><img src='".$ruta_imagen."' width='".$img_width."' height='".$img_height."' class='image_car'></a>";
echo $ruta_img;


This code works perfect inside the code for create the shortcode , but the problem it´s if i use the shortcode and put active the comments for ones post or page , the form and comments no show

I don´t understand what have bada this code for no let show the comments , if i don´t use this shortcode the comments show other time and the form

Please if you can tell me which it´s the problem perfect for me

Thank´s , regards !


This question is very hard to understand but I think that you might need to put wp_reset_query() or wp_reset_postdata() after your Loop (after endwhile;) to to reset the loop and/or the $post variable.

  • Yesssssssssss works !!!!!!!!!! Aug 26 '13 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.