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

<Title> tag being split accross multiple lines when genereated from MasterPage html master-pages

I have created a website in VS 2008 (C#) that is using masterpages.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.