wordpress 过滤短代码前的P 标签

在添加段代码时,若段代码前面有空行,导致显示时出现很大的上下留白,所以用此代码可以解决这个问题。

食用方法

将下面的代码放到主题functions.php中即可

<code>
function fix_shortcodes($content){   
        $array = array (
            '<p>[' => '[', 
            ']</p>' => ']', 
            ']<br />' => ']'
        );
        $content = strtr($content, $array);
        return $content;
    }
add_filter('the_content', 'fix_shortcodes');
</code>

0 thoughts on “wordpress 过滤短代码前的P 标签
添加一条新回复 回到顶部

亲爱的,主人已经关闭了这篇文章的评论 。