Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从文章中删除块引号和文本_Javascript_Php_Wordpress - Fatal编程技术网

Javascript 从文章中删除块引号和文本

Javascript 从文章中删除块引号和文本,javascript,php,wordpress,Javascript,Php,Wordpress,这段代码从我的Wordpress帖子中删除图像,并将图像放在适当的位置 HTML-代码片段 <?php preg_match_all('/(<img [^>]*>)/', get_the_content(), $images); for( $i=0; isset($images[1]) && $i < count($images[1]); $i++ ) { echo $images[1][$i]; } ?> <?php $c

这段代码从我的Wordpress帖子中删除图像,并将图像放在适当的位置

HTML-代码片段

<?php
  preg_match_all('/(<img [^>]*>)/', get_the_content(), $images);
  for( $i=0; isset($images[1]) && $i < count($images[1]); $i++ ) {
  echo $images[1][$i];
}
?>
<?php
$content = preg_replace('/(<img [^>]*>)/', '', get_the_content());
$content = apply_filters('the_content', $content);
echo $content;
?>

此代码从帖子中删除文本,并仅发布文本。我希望这段代码删除'块引号'文本和常规文本分开,这样我就可以把块引号放在一个不同的部分,而不是页面上的常规文本

HTML-代码片段

<?php
  preg_match_all('/(<img [^>]*>)/', get_the_content(), $images);
  for( $i=0; isset($images[1]) && $i < count($images[1]); $i++ ) {
  echo $images[1][$i];
}
?>
<?php
$content = preg_replace('/(<img [^>]*>)/', '', get_the_content());
$content = apply_filters('the_content', $content);
echo $content;
?>

我试过包括

if(preg_match('~<blockquote>([\s\S]+?)</blockquote>~', $block, $matches))
if(预匹配(“~([\s\s]+?)~”,$block,$matches))

但似乎无法让它发挥作用。我想把每篇文章中的图像、块引号和文本分开,这样我就可以把它们放在页面的不同位置

有什么理由不只是使用
stru\u replace
?无法使用不需要的标记数组。或者白名单,然后用标签。我从来没有用过,这是另一篇文章的结果,也是最流行的答案