从Wordpress帖子中删除块引号


removing block quote from Wordpress post

我有下面的代码,它将Wordpress帖子的内容放到页面上(图像被删除)

<?php
  $content = preg_replace('/<blockquote>(.*?)<'/blockquote>/', '', get_the_content());
  $content = preg_replace('/(<img [^>]*>)/', '', get_the_content());
  $content = wpautop($content); // Add paragraph-tags
  $content = str_replace('<p></p>', '', $content); // remove empty paragraphs
    echo $content;
?>

我也想删除块引号,它确实删除了,但无论放在当前位置,它都不会删除块引号。

放在"img"行之后,它确实删除了块引号,但图像被放回中

您应该使用

strip_tags——从字符串中剥离HTML和PHP标记

$string = get_the_content();
// remove all html tags
echo strip_tags($string); 
// Allow specific tags such as <p> and <a>
echo strip_tags($string, '<p><a>');

要删除blockquote元素中样式化的引号,您需要修改:before伪元素,该元素包含:content: "

要添加的CSS:

blockquote::before {
    content:none;
}