필자 내가 SRC = "www.youtube로 시작하는 SRC를 포함하는 경우에만 iframe을 대상으로 지정할PHP/워드 프레스는 preg_match
사업부 클래스 ="비디오 컨테이너 "의 모든 iframe이의 포장 다음과 같은 기능을 가지고
구체적 않는이 기능을 수정하는 방법이인가?
감사합니다 사전에.
function div_wrapper($content) {
// match any iframes
$pattern = '~<iframe.*</iframe>~';
preg_match_all($pattern, $content, $matches);
foreach ($matches[0] as $match) {
// wrap matched iframe with div
$wrappedframe = '<div class="video-container">' . $match . '</div>';
//replace original iframe with new in content
$content = str_replace($match, $wrappedframe, $content);
}
return $content;
}
add_filter('the_content', 'div_wrapper');
foreach의 첫 번째 줄에'if (! condition) continue; '가 있습니다. 조건을 타겟 조건으로 만드십시오 (src는 무엇이든 시작합니다). – Patashu