开发者

Wordpress inserts <p></p> next to shortcode return value

I have created the following shortcode code:

<?php

开发者_开发技巧function box_handle($atts, $content='')
{
    extract(
    shortcode_atts(array(
                        'size' => 'narrow'), $atts));
    return '<div class="box '.$size.'">'.$content.'</div>';
}

add_shortcode('box', 'box_handle');

?>

And this:

[box]<h2>Title</h2>
Content
Content
Content[/box]

Gives me

<div class="box narrow"><br>
<h2>Title</h2>
<p>Impingement<br>
Content<br>
Content<br>
Content</p></div>
<p></p>

The problem here being the extra <br> at the top, after the opening tag. Keep reading and you will find a second error, the unwarranted <p></p>... How can I fix this? Naturally, I have gone through the HTML code in the admin panel and tried to weed out any new lines and other things around the markup which may cause this but I have not been able to fix it.


There is a plugin, which should let you disable the wpautop()-function on a per-post-basis. I didn't tested that plugin yet.

http://plugins.trac.wordpress.org/wiki/TextControl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜