我有一个自定义字段,用户可以在其中选择div的背景。但是在右上角或屏幕显示:
35 ,,,4c5a6729201043.55e72a8144693 ,,, image / jpeg,http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg,1200,1200,Array');
我用来让用户选择背景(及其内容)的代码是:
<?php $image = get_field( 'slide_bg1' );
if ( !empty( $image ) ) { ?>
<div class="slide1" style="background-image:url('<?php echo $image['url']; ?>');">
<?php the_field('slide_bg1'); ?>');<div class="slide1-cont"><p class="slide-text"><h1><?php the_field('slide_title1'); ?></h1><img src="<?php bloginfo('template_directory')?>/images/line.png" /></p>
<p><?php the_field('slide_content1'); ?></p></div>
</div>
<?php } ?>
$ image的var_dump:
array(10){[“id”] =&gt; int(35)[“alt”] =&gt; string(0)“”[“title”] =&gt; string(28)“4c5a6729201043.55e72a8144693”[“caption”] =&gt; string(0)“”[“description”] =&gt; string(0)“”[“mime_type”] =&gt; string(10)“image / jpeg”[“url”] =&gt; string(86)“http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg”[“width”] =&gt; int(1200)[“height”] =&gt; int(1200)[“sizes”] =&gt; array(9){[“thumbnail”] =&gt; string(94)“http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-150x150.jpg”[“thumbnail-width”] =&gt; int(150)[“thumbnail-height”] =&gt; int(150)[“medium”] =&gt; string(94)“http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg”[“medium-width”] =&gt; int(300)[“medium-height”] =&gt; int(300)[“large”] =&gt; string(96)“http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-1024x1024.jpg”[“large-width”] =&gt; int(900)[“large-height”] =&gt; int(900)}}
左上角的屏幕截图
如何摆脱这个文字?这是一个错误吗?
答案 0 :(得分:1)
这里添加了正确的代码
<?php $image = get_field( 'slide_bg1' );
if ( !empty( $image ) ) { ?>
<div class="slide1" style="background-image:url(<?php echo $image['url']; ?>);">
<div class="slide1-cont"><p class="slide-text"><h1><?php the_field('slide_title1'); ?></h1><img src="<?php bloginfo('template_directory')?>/images/line.png" /></p>
<p><?php the_field('slide_content1'); ?></p></div>
</div>
<?php } ;?>