Make thumbnail clickable - Wordpress

0

Good afternoon,

I'm editing a Wordpress theme and would like to make the thumbnail, which is added as background, clickable with the post link.

The look looks like this:

Butonlythetitleofthepostisclickable,Iwouldlikethebackgroundtoo.

Thecontentcodeinhomeisasfollows:

articleid="post-<?php the_ID(); ?>" <?php post_class('section'); ?>>

<?php if ( has_post_thumbnail() ) :
    $image_id = get_post_thumbnail_id();
    $url = wp_get_attachment_image_src( $image_id, 'magnus-large' );
?>

<div class="section-image" style="background-image: url(<?php echo esc_attr( $url[0] ); ?>);">

<?php else: ?>

    <div class="section-image">

<?php endif; ?>

</div><!-- .section-image -->

<div class="section-inner">
    <header class="entry-header">
        <?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
        <?php if ( 'post' == get_post_type() ) : ?>
        <?php endif; ?>
    </header><!-- .entry-header -->
</div><!-- .section-inner -->

    
asked by anonymous 01.10.2018 / 20:08

1 answer

0

Good afternoon,

Try to do this <a><div> .... </div></a> like this:

<a href="link">
  <div class="section-image" style="background-image: url(<?php echo 
  esc_attr($url[0] ); ?>);">
</a>

I hope I have helped.

    
01.10.2018 / 22:37