0
<?php
$i = 0;
$page = get_the_content();
$doc=new DOMDocument();
$doc->loadHTML($page);
$xml=simplexml_import_dom($doc);
$images=$xml->xpath('//img');
foreach ($images as $img) {
list($width, $height, $type, $attr) = getimagesize($img['src']);
if ($height > 149) {
echo '<img src="' . $img['src'] . '" alt=" ' . $img['alt'] . ' - funny and hot pictures" title=" ' . $img['title'] . ' - funny fail picture dump" onerror=\'this.style.display="none" \'><br>';
$i++;
if ($i == 3) { break;}
}
else
{
// don't display
}
}
?>
我用"<?php the_content(); ?>"
替換了上面的一段代碼。它應該刪除我的文章中的所有文字,只留下很好的圖像。但是當我嵌入一個視頻時,php就會中斷。我如何讓帖子顯示YouTube視頻?我需要我的wordpress主題幫助
你想嵌入一個youtube視頻代替那個圖像嗎? – aNi
不,我想讓我的wordpress主題能夠「獲得」圖像和yourtube視頻。與當前的代碼,當我嵌入視頻的PHP得到破壞我的WordPress主題不會讓我顯示視頻。 – user590896