dougu1990 2015-12-23 00:06
浏览 75
已采纳

针对wordpress背景的另一个图像

I have a WordPress site which is set up to display posts on the index page as large thumbnails. The post loop brings in each and I have their 'featured image' set as the background of each 'cell' using

<?php
    if (has_post_thumbnail()) {
        $thumbnail_data = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'my-fun-size' );
        $thumbnail_url = $thumbnail_data[0];
    }
?>

<div class="bg-img-LC" style="background-image:url('<?php echo $thumbnail_url ?>');">

... content ...

When selected they go to a single.php page which has a custom header.php which puts the featured image as the background of the header's jumbotron using

<?php
    if (has_post_thumbnail()) {
        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
    }
?>

 <div class="jumbotron-int row" style="background-image:url('<?php echo $large_image_url[0]; ?>');">

... content ...

I want a different image to be used as the background of the header for the post. Whether that is a tagged image from the posts content, a second 'feature image' (if that's even possible), or however this can be done. Each post will have it's own header, but I DON'T want it to be the same as the feature from the index page

  • 写回答

1条回答 默认 最新

  • dongtan3395 2015-12-23 02:30
    关注

    use ACF (plugin) image so in the post you will have 2 images one featured and other for header ...

    ACF image link

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向