-2

I'm trying to dynamically add background inside CSS using php, using the Wordpress post image.

background: <?php if(has_post_thumbnail()){ 
                $img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'destacados');
                echo 'url(".$img['0'].") no-repeat center'  } ?>;
4

1 回答 1

1
background: <?php if(has_post_thumbnail()){ 
                $img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'destacados');
                echo "url('".$img['0']."') no-repeat center";
             } ?>;

引号是错误的,并且缺少分号。

于 2014-05-29T17:24:40.400 回答