Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter dmatthams

    (@dmatthams)

    Thanks for the reply, but i couldn’t get this to work, the IF statement returned false even if there was a featured image to a post. Further googling led me to some code which returns the url and works beautifully:

    <div class="feat" style="background-image: url('<?php
    $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
    foreach ( $attachments as $attachment_id => $attachment ) {
    	echo wp_get_attachment_url( $attachment_id, 'medium' );
    } ?>')">
Viewing 1 replies (of 1 total)