So I have some code that I tested and it works for a regular page/post in my functions.php
function div_wrapper($content) {
static $foo_called = false;
if ($foo_called) return;
$foo_called = true;
//echo "here";
$pattern = '~<iframe.*</iframe>~';
preg_match_all($pattern, $content, $matches);
foreach ($matches[0] as $match) {
// wrap matched iframe with div
$wrappedframe = '<div class="iframe-container">' . $match . '</div>';
//replace original iframe with new in content
$content = str_replace($match, $wrappedframe, $content);
echo $content;
}
return $content;
}
add_filter('the_content', 'div_wrapper', 98 );
So all of my iframes are on woocommerce product pages. The filter hook "the_content" seems to not be affecting the woocommerce product pages. I have tried using different hooks and actions and tried using woocommerce hooks/actions and still, I can never get this code to run and work on the iframes I need. Any help or guidance would be greatly appreciated.