我的单曲开头有以下代码。php循环,将帖子特色图像显示为背景。
<?php $featured_background = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), \'full\' ); ?>
<div class="parallax" id="parallax1" style="background: url(<?php echo $featured_background[\'0\'];?>) !important; background-position: 50% 50% !important; background-repeat: no-repeat !important; background-size: cover !important; background-attachment: fixed !important;" data-stellar-background-ratio=".5">
<div class="parallax-content">
Some content
</div>
</div>
我准备好了。样式表中的视差为600px高。当然,这会给没有特色图片的帖子带来问题。
似乎我需要一个条件语句,只有在帖子有缩略图时才显示上面的代码。
我看过wordpress抄本,但不确定如何将那里的教导应用到我的案例中。由于所有的HTML,看起来他们会大量使用echo命令。
我想我理解了声明的第一部分,大致如下:
<?php
if ( has_post_thumbnail() ) {
echo\'my html code as above\'
}
else {
just get on with rendering the rest of the page
}
?>
但是我不明白如何告诉它继续在else语句中呈现页面。