Shortcode output adding
after new line

前端 未结 2 864
误落风尘
误落风尘 2021-02-06 08:19

I\'m trying to create a shortcode to add a CSS style attribute to a page. I added the following code to my theme\'s functions.php.

function add_style( $atts, $co         


        
2条回答
  •  佛祖请我去吃肉
    2021-02-06 09:19

    The solution I found to my problem was to replace remove "
    "
    using str_replace();

    function add_style( $atts, $content = null ) {
        $pure_content = str_replace("
    ","",$content); return ''; } add_shortcode( 'style', 'add_style' );

提交回复
热议问题