• I’ve added some custom shortcode in my functions.php but when I insert the shortcode on the page it wraps the resulting output in <pre> tags which results in undesired styling.
    I just want the shortcode to display without these tags being automatically included. How can do this?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter stemie

    (@stemie)

    I forgot to add there are no <pre> tags in the function I added, it appears to be automatically generated by the theme.

    Here is the function Im using

    function myLoop($atts, $content = null) {
    	extract(shortcode_atts(array(
    		"pagination" => 'true',
    		"query" => '',
    		"category" => '',
    	), $atts));
    	global $wp_query,$paged,$post;
    	$temp = $wp_query;
    	$wp_query= null;
    	$wp_query = new WP_Query();
    	if($pagination == 'true'){
    		$query .= '&paged='.$paged;
    	}
    	if(!empty($category)){
    		$query .= '&category_name='.$category;
    	}
    	if(!empty($query)){
    		$query .= $query;
    	}
    	$wp_query->query($query);
    	ob_start();
    	?>
    
    	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    		<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo the_title(); ?></a></h3>
    		<?php the_excerpt(); ?>
    	<?php endwhile; ?>
    
    	<?php if(pagination == 'true'){ ?>
    	<div class="navigation">
    	  <div class="alignleft"><?php previous_posts_link('« Previous') ?></div>
    	  <div class="alignright"><?php next_posts_link('More »') ?></div>
    	</div>
    	<?php } ?>
    	<?php $wp_query = null; $wp_query = $temp;
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;
    }
    add_shortcode("loop", "myLoop");

    I have the same problem with shortcode output being wrapped in <pre> tags.

    Shouldn’t it be assumed we are wrapping our own content and give us greater control?

    Thread Starter stemie

    (@stemie)

    Such a great theme, any chance anyone can help with this problem? Please…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Prevent shortcode being wrapped in pre div tag by default’ is closed to new replies.