Remove <pre> tag from shortcode loop

I have shortcode that generates a list of posts, however the posts are automatically wrapped in <pre> tags and I am unsure how to remove them. Example:

<pre><li><a href=''><img src=''></a></li></li><pre>

This is the shortcode:

[loop the_query="tag=news"]

This is the function:

 function custom_query_shortcode($atts) {

      "the_query" => ''
   ), $atts));

   $the_query = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))',   $the_query);
   $the_query = preg_replace('~&#0*([0-9]+);~e', 'chr(\\1)', $the_query);


   $output = '';
   $temp_title = '';
   $temp_link = '';
   $temp_thumb = '';

   if (have_posts()) : while (have_posts()) : the_post();

      $temp_title = get_the_title($post->ID);
      $temp_link = get_permalink($post->ID);
      $temp_thumb = the_post_thumbnail( 'side-thumb' );

      $output .= "<li><a href='$temp_link'>$temp_title <img src='$temp_thumb'></a></li>";

   endwhile; else:

      $output .= "nothing found.";


   return $output;

add_shortcode("loop", "custom_query_shortcode");


I would have a look at the following :

  • whats are you doing the regular expression bits ? are they necessary ?
  • missing ul tag could be an issue
  • query_posts is a bit dodgy overall for something like this and you really should change to using WP_Query to avoid all sorts of voodoo mischief, its the better way to run multiple loops and I suspect, as query_posts hijacks the main query, doing this essentially inside of another loop may be whats causing all sorts of tom foolery.

Good luck.

Need Your Help

Why does ruby script stop when trying to start unicorn_rails as daemon?

ruby ruby-on-rails-3 bash unicorn

I'm trying to start unicorn_rails in a ruby script, and after executing many commands in the script, when the script gets to the following line

How to cast JSONArray to int array?

java json

I'm having problems with the method JSONObject sayJSONHello().