从帖子文本中删除块引用 - Wordpress

use*_*879 7 html php wordpress

我有一个Wordpress网站,我想删除帖子中的块引号,只放置常规文本.(也想删除文本中的任何图像,我只想要常规文本)

这段代码执行我想要的OPPOSITE - 取出块引用和帖子.我希望它发布其他文本而不是块引用.

<?php
        // get the content
        $block = get_the_content();

        // check and retrieve blockquote
        if(preg_match('~<blockquote>([\s\S]+?)</blockquote>~', $block, $matches))

        // output blockquote
        echo $matches[1];
?>  
Run Code Online (Sandbox Code Playgroud)

Nad*_*dav 1

您需要的是内容过滤器。将以下内容添加到您的functions.php文件中

add_filter( 'the_content', 'rm_quotes_and_images' );
function rm_quotes_and_images($content) 
{
   $content = preg_replace("~<blockquote>([\s\S]+?)</blockquote>~", "", $content);
   $content = preg_replace("/<img[^>]+>/i", "", $content);          
   return $content;
}
Run Code Online (Sandbox Code Playgroud)