Link Featured Background Image to Post
-
Hello,
I am creating a custom child theme based on the default Twentysixteen theme. For the home page, I am displaying 9 post previews. I am using this code in my content.php file to make the featured image a background image for each post.<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> <div class="article" style="background: url('<?php echo $thumb['0'];?>')">
But how can I make the background image (or its div container) a link to its respective post? I’ve tried several things and am not having any luck.
Thanks for any help!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Link Featured Background Image to Post’ is closed to new replies.