Remove auto added

from a page that has no literal content (uses shortcodes)

后端 未结 5 709
我在风中等你
我在风中等你 2021-01-05 07:16

I have a WordPress powered website that on the homepage uses a static page with nothing but shortcodes to generate the content.

The page gets these shortcodes by set

5条回答
  •  自闭症患者
    2021-01-05 07:23

    There are a few things you can try.

    You can pospone the wp_autop because it processes before the shortcode output:

    remove_filter( 'the_content', 'wpautop' );
    add_filter( 'the_content', 'wpautop' , 12);
    

    Or use the cleanup_shortcode_fix() function that should help with your issue:

    function cleanup_shortcode_fix($content) {
        $array = array('

    [' => '[', ']

    ' => ']', ']
    ' => ']', ']
    ' => ']'); $content = strtr($content, $array); return $content; } add_filter('the_content', 'cleanup_shortcode_fix'); $string = preg_replace_('/

    s*

    /', '', $string); add_filter('the_content', 'cleanup_shortcode_fix', 1);

提交回复
热议问题