Wordpress-在PHP的短代码中使用特色图像作为div背景

Wordpress-在PHP的短代码中使用特色图像作为div背景,php,css,wordpress,shortcode,Php,Css,Wordpress,Shortcode,我试图在wordpress中获取一篇文章的特征图像,并将其作为div的背景图像输出,然后将其与div的右下角对齐 到目前为止,我有下面显示的代码,但是背景图像:url('.wp_get_attachment_url())返回为背景图像:url()执行代码时 提前感谢任何能提供帮助的人 <?php query_posts(array( 'category_name' => 'what-we-do')); if(have_posts()) : while(have_pos

我试图在wordpress中获取一篇文章的特征图像,并将其作为div的背景图像输出,然后将其与div的右下角对齐

到目前为止,我有下面显示的代码,但是
背景图像:url('.wp_get_attachment_url())
返回为
背景图像:url()执行代码时

提前感谢任何能提供帮助的人

<?php
    query_posts(array( 'category_name' => 'what-we-do'));
    if(have_posts()) : while(have_posts()) : the_post();
?>
<div>
    <?php 
        echo do_shortcode( '
            [expand title="' . get_the_title() . '" swaptitle="Close" trigpos="below" id="' . get_the_ID() . '" trigclass="arrowright" rel="whatwedo-highlander"]
                <h4 class="collapse-inner-title">' . get_the_title() . '</h4>
                <div class="whatwedo-collapse-background-img" style="background-image: url(' . wp_get_attachment_url() . '); background-position: right bottom;">
                    <div class="whatwedo-collapse-content">' . get_the_content() . '</div>
                </div>
            [/expand]
        ' ); 
    ?>
</div>

<?php
    endwhile;
    endif;
    wp_reset_query();
?>

试试这个:

$image=wp\u get\u attachment\u image\u src(get\u post\u thumbnail\u id($post->id),'single post thumbnail')


那么,在设置背景图像时,请使用us
$image[0]
,先生,您是位绅士。感谢您的快速响应和明确指示。工作得很好。