WordPress发布在徽标后面的特色图像背景标题

时间:2017-02-10 15:19:21

标签: php html wordpress

我会尝试将精选图片作为徽标背后的背景标题,但结果并不是只显示此字符串的图像:

">    

所以我认为代码有问题,但我不知道是什么。

这是我的代码:

   <?php else: ?>
     <div id="header-video">
      <div id="video_bg" class="img_full_responsive" style="width:100%;background:url('<?php echo get_the_post_thumbnail($post_id, 'image-featured'); ?> ">
 <?php  include(TEMPLATEPATH."/template/header/header-logo.php"); ?>
     </div>
   </div>
 <?php endif; ?>

2 个答案:

答案 0 :(得分:0)

$post_thumbnail_id  = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );

<div id="video_bg" class="img_full_responsive" style="width:100%;background:url('<?php echo echo $post_thumbnail_url; ?> ">
  <img src="<?php bloginfo('template_directory'); ?>/template/header/header-logo.php">
</div>

答案 1 :(得分:0)

网站:

https://www.grenzenlostour.de/reiseberichte/asien/kazakhstan/die-steppe-und-die-suche-nach-schatten/

我希望与索引网站上的视频相同,特色图片表示徽标。她的完整代码:

 <?php if(is_home()): ?>
  <div id="header-video">
<div id="video_bg" style="width:100%;background:url('<?php echo esc_url($ilgelo_options['ilgelo-video-image']['url']); ?>');"
 data-vide-bg="mp4: <?php echo  preg_replace('/\\.[^.\\s]{3,4}$/', '', $ilgelo_options['ilgelo-video-mp4']['url']);?>,
  webm: <?php echo  preg_replace('/\\.[^.\\s]{3,4}$/', '', $ilgelo_options['ilgelo-video-webm']['url']);?>,
  ogv: <?php echo  preg_replace('/\\.[^.\\s]{3,4}$/', '', $ilgelo_options['ilgelo-video-ogv']['url']);?>,
  poster: <?php echo  preg_replace('/\\.[^.\\s]{3,4}$/', '', $ilgelo_options['ilgelo-video-image']['url']);?>"
 data-vide-options="position: 0% 50%">

    <!--<span class="section_mask" style="background-color: <?php echo  $ilgelo_options['ilgelo-color-video-mask']?>; opacity: <?php echo  $ilgelo_options['ilgelo-opacity-video-mask']?>;"></span>-->

     <?php  include(TEMPLATEPATH."/template/header/header-logo.php"); ?>

</div>
</div>
 <?php else: ?>
<div id="header-video">

<div id="video_bg" class="img_full_responsive" style="width:100%; background:url('<?php echo get_the_post_thumbnail($post_id, 'image-featured'); ?> ">
 <?php  include(TEMPLATEPATH."/template/header/header-logo.php"); ?>
 </div>
 </div>