Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fannshop

    (@fannshop)

    I’ve solved this using a function. Incase some else needs this I’m posting it here below. Add it to your functions.php it will remove the unwanted <p> </p> and leftover </p> tag in de sidebar instead of the content.

    function fannshop_remove_unwanted_p_tags($content) {

    ? ? // Remove closing </p> tags that appear right before </li>

    ? ? $content = preg_replace('/<\/label><\/p>/', '</label>', $content);

    ? ? // Remove opening <p> tags that appear right before <span class="wpf_item_count">

    ? ? $content = preg_replace('/<p>\s*(<span class="wpf_item_count">)/', '$1', $content);

    ? ? // Remove closing </p> tags that appear right after </span>

    ? ? $content = preg_replace('/(<\/span>)\s*<\/p>/', '$1', $content);

    ? ? return $content;

    }

    function buffer_start() {

    ? ? ob_start('remove_unwanted_p_tags');

    }

    function buffer_end() {

    ? ? ob_end_flush();

    }

    // Hook into the template rendering

    add_action('wp_head', 'buffer_start');

    add_action('wp_footer', 'buffer_end');
    Thread Starter fannshop

    (@fannshop)

    There shouldn’t be any <p> or closing </p> tags but there are, and those are not added from the admin. So does this mean your plugin cannot be used on FSE Block themes only on classic themes? Too bad, in that case I’ll have to look for another solution.

Viewing 2 replies - 1 through 2 (of 2 total)