首页 > 解决方案 > 在内联 CSS 中使用时,URL 采用自动间距

问题描述

我遇到了一个问题。我在内联 CSS 中使用了 wp get_the_post_thumbnail_url(),但它不能正常工作。URL 通过删除的斜杠占用空格。

if ( has_post_thumbnail() ) { 
                            $startnext_features_box_markup .='
                            <div class="single-repair-services" style="background-image: url("'.get_the_post_thumbnail_url().'");">';

结果显示 在此处输入图像描述

标签: phpwordpressurl

解决方案


试试这个编辑过的代码

if ( has_post_thumbnail() ) { 
    $image = get_the_post_thumbnail_url();

    $startnext_features_box_markup .='
    <div class="single-repair-services" style="background-image: url(\''.$image.'\');">';

推荐阅读