Javascript 从文章中删除块引号和文本
这段代码从我的Wordpress帖子中删除图像,并将图像放在适当的位置 HTML-代码片段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
<?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
?无法使用不需要的标记数组。或者白名单,然后用标签。我从来没有用过,这是另一篇文章的结果,也是最流行的答案