I'm trying to pull out everything inside <blockquote>
tags from my wordpress posts.
I've tried using
<?php
$content = preg_replace('/<blockquote>(.*?)<\/blockquote>/', '', get_the_content());
echo $content;
?>
But was told preg_replace
isn't a good method, and can't figure out the code to put the blockquote
back in (in another location)
Something like this should do the trick:
add_filter( 'the_content', 'rm_quotes' );
function rm_quotes($content) {
$content = preg_replace("~<blockquote>([\s\S]+?)</blockquote>~", "", $content);
return $content;
}
Applying it in a filter is your best option.