Support » Plugin: Flexible Posts Widget » Editing The Template

  • Resolved Xarcell


    I’m wanting to have a different template to use other than the widget.php, simply because I am using/making a responsive horizontal theme and I need little more flexibility.

    I have already cloned the “widget.php” and named it “dashboard-widget.php”.

    How can I make the featured image or image in the post, appear as the background of the list item? CSS & HTML is my thing, but not PHP…


    <li id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="background: url(GRAB_THE_URL) center center no-repeat;">


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author DaveE


    Hi Xarcell,

    Something like this should do the trick:

    	// Get the feature image source for use as background...
    	$src = $style = '';
    	if( has_post_thumbnail() ) {
    		$src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'project-large' );
    		$style = ' style="background:url(' . $src[0] . ') center center no-repeat;" ';
    <li id="post-<?php the_ID(); ?>" <?php post_class(); ?><?php echo $style; ?>>

    In this example, I’m getting the feature image’s source URL using wp_get_attachment_image_src() and then setting <li> style attribute to the use that image source for the background image.


    Plugin Author DaveE


    Hi Xarcell,

    Since I haven’t heard that you are still having trouble I’m going to close this thread. Feel free to respond and reopen it if you still have trouble.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Editing The Template’ is closed to new replies.