• Resolved Wabsnasm

    (@wabsnasm)


    I’ve been searching around and found loads of people having the same problem, but no definitive solution.

    If I add my own shortcode, and use it as a block, like

    [code]
    Contents of code
    [/code]

    Then the output of that shortcode starts with </p> and ends with <p>. How can I output it without these?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Can you post the link to your site to demonstrate this?

    Thread Starter Wabsnasm

    (@wabsnasm)

    Sorry, don’t have a link to that. But it seems such a widely-encountered problem, I’m surprised that there’s not a definitive answer or fix in the core.

    Here’s a temporary fix that I don’t really like

    function shortcode_func($attr, $content) {
        return fix_shortcode( do_shortcode($content) );
    }
    
    function fix_shortcode($content) {
        return preg_replace(array('/^<\/p>/i', '/<p>$/i'), array('', ''), $content);
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcodes: block shortcodes have extra `</p>` and `<p>`’ is closed to new replies.