Wordpress Featured image display

Hey guys im using css background image to resize and center the wordpress featured image however im strugling to get this to dispaly using PHP.

The code im tyring to get to work is as follows, as you can see im thing to inline style within the loop. However this is not displaying any results.

     <div class="outer">

    <section class="post">
        <div class="postTop">
            <div class="postLeft">
                
                
     

        <div style="background-image:url(<?php if ( has_post_thumbnail() ) { the_post_thumbnail() } ?>)" id="postBox">

        </div>
            </div>
            <div class="postRight">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <?php the_excerpt(); ?>
            </div>
        </div>
        <div class="postBottom">
            
            <date><?php the_date(); ?></date> 
            
            <a href="<?php comments_link(); ?>">
	<?php
	printf( _nx( 'One Comment', '%1$s Comments', get_comments_number(), 'comments title', 'textdomain' ), number_format_i18n( 						get_comments_number() ) ); ?>
</a>
            
       
             
            <div class="readmore"><a href="<?php the_permalink(); ?>">Read More</a></div>
        </div>
    </section>

</div>
        </div>

How does the resulting html look, does the url appear?

Try this:

<?php $feature_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>

and then

<div style="background-image:url('<?php echo $feature_Image[0] no-repeat; ?>')" id="postBox">

Sorry late reply been on holidays.

I tried this any it still dosnt display the image. Infact has the same result as my code just cuts the page from loading and infact dose not load the content.php file at all.

The page stops loading at this poing and content.php file is not loaded at all.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.