首页 文章

从Wordpress帖子中删除块引用

提问于
浏览
1

我有以下代码,将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;
?>

我想删除它所做的块引用,但是它现在放在它当前没有删除blockquote的地方 .

放置在'img'行后,它会删除块报价,但图像会被放回去

2 回答

  • 0

    你应该用

    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>');
    
  • 0

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

    要添加的CSS:

    blockquote::before {
        content:none;
    }
    

相关问题