由于以下代码,是否有任何理由发生这种情况?所有显示的都是变量,即图像。
<?php $featured_image = the_post_thumbnail();?>
<?php if (is_page(7) || is_page(12))
echo '<div class="featured_image">' . $featured_image . '</div>'
?>
答案 0 :(得分:0)
<?php
$featured_image = the_post_thumbnail();
if (is_page(7) || is_page(12)) {
echo '<div class="featured_image">' . $featured_image . '</div>';
}
?>
答案 1 :(得分:0)
该函数本身回应了img:http://codex.wordpress.org/Function_Reference/the_post_thumbnail
尝试:
<?php
if ( has_post_thumbnail() && (is_page(7) || is_page(12))) {
echo '<div class="featured_image">';
the_post_thumbnail();
echo '</div>';
}
?>
您所看到的是回声功能的返回值。