简体   繁体   中英

targeting another image for wordpress background

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

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

ACF image link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM