我不确定是否可以做到这一点,因为无论我多么努力,都找不到任何可以帮助我的东西。我Ajax
习惯在按下按钮时将其加载到帖子中。所加载的帖子由我的内的我的函数格式化functions.php
。一切正常,我要解决的问题是background-image:
属性必须是属性,inline css
以便它可以从我的自定义字段中提取图像。但是,所有这些都可以在模板文件中完美地工作。不管我尝试什么,无论我尝试什么,都会functions.php
拒绝我的内联样式作为背景图像。
这是我全部的If语句:
if ($loop -> have_posts()) : while ($loop -> have_posts()) : $loop -> the_post();
if ($_SESSION["load_type"] == 'home')
{
$out .= '<div class="small-6 large-3 columns end thumb">
<div class="grid">
<figure class="effect-zoe">
'.get_the_post_thumbnail( get_the_ID(), $size, $attr ).'
<figcaption>
<h2>'.get_the_title().'</h2>
<hr class="light">
<p class="description">'.get_the_content().'</p>
</figcaption>
</figure>
</div>
</div>';
}
else
if ($_SESSION["load_type"] == 'category')
{
$out .= '<div class="small-6 large-6 columns end thumb under">
<div id="case">
<div class="th" id="element" >
<a class="fill-div" href="'. get_permalink($post->ID) .'"></a>
</div>
</div>
<div class="brief">
<a href="'. get_permalink($post->ID) .'">'.get_the_title().'</a>
<p class="suppy">Supplier</p>
<p>'.get_the_excerpt().'</p>
<a class="more-btn" href="'. get_permalink($post->ID) .'">More</a>
</div>
</div>';
}
else
if ($_SESSION["load_type"] == 'product')
{
$out .= '<div class="small-6 large-3 columns">
<div class="small-6 large-12 columns end no-pad morepro" style="background-image: url(''.the_field(product_image).'')">
<a class="fill-div" href="'. get_permalink($post->ID) .'"></a>
</div>
<h2 class="product-load">'.get_the_title().'</h2>
</div>';
}
endwhile;
endif;
wp_reset_postdata();
die($out);
这就是我遇到的麻烦部分,每次我尝试加载到网站时都会崩溃整个网站 background-image:
if ($_SESSION["load_type"] == 'product')
{
$out .= '<div class="small-6 large-3 columns">
<div class="small-6 large-12 columns end no-pad morepro" style="background-image: url(' '.the_field(product-image).' ')">
<a class="fill-div" href="'. get_permalink($post->ID) .'"></a>
</div>
<h2 class="product-load">'.get_the_title().'</h2>
</div>';
}
enter code here
谁能看到我要去哪里错了?
改变以下
style="background-image: url(' '.the_field(product-image).' ')"
进入
style="background-image: url('.the_field("product-image").')"
这在以下情况下应该有效:
内背景图片行情应该是可选此。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句