显示图像名称的 Wordpress 自定义字段
Wordpress custom fields displaying image name
我有一个自定义字段,用户可以在其中 select div 的背景。但是在右上角或屏幕上显示:
35, 4c5a6729201043.55e72a8144693, image/jpeg, http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg, 1200, 1200, 数组');
我用来让用户 select 背景(及其内容)的代码是:
<?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 } ?>
var_dump 个 $image:
array(10) { ["id"]=> int(35) ["alt"]=> string(0) "" ["title"]=> string(28 ) "4c5a6729201043.55e72a8144693" ["caption"]=> 字符串(0) "" ["description"]=> 字符串(0) "" ["mime_type"]=> 字符串(10) "image/jpeg" ["url"]=> string(86) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg" ["width"]=> int(1200) ["height"]=> int(1200) ["sizes"]=> array(9) { ["thumbnail"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-150x150.jpg" ["thumbnail-width"]=> 整数(150) ["thumbnail-height"]=> 整数(150) ["medium"]=> 字符串(94) " http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg" ["medium-width"]=> int(300) ["medium-height"]=> int(300) ["large"]=> string(96) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-1024x1024.jpg" ["large-width"]=> 整数(900) ["large-height"]=> 整数(900) } }
左上角截图
自定义字段截图
如何删除此文本?是不是出错了?
这里添加了正确的代码
<?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 } ;?>
我有一个自定义字段,用户可以在其中 select div 的背景。但是在右上角或屏幕上显示:
35, 4c5a6729201043.55e72a8144693, image/jpeg, http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg, 1200, 1200, 数组');
我用来让用户 select 背景(及其内容)的代码是:
<?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 } ?>
var_dump 个 $image:
array(10) { ["id"]=> int(35) ["alt"]=> string(0) "" ["title"]=> string(28 ) "4c5a6729201043.55e72a8144693" ["caption"]=> 字符串(0) "" ["description"]=> 字符串(0) "" ["mime_type"]=> 字符串(10) "image/jpeg" ["url"]=> string(86) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg" ["width"]=> int(1200) ["height"]=> int(1200) ["sizes"]=> array(9) { ["thumbnail"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-150x150.jpg" ["thumbnail-width"]=> 整数(150) ["thumbnail-height"]=> 整数(150) ["medium"]=> 字符串(94) " http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg" ["medium-width"]=> int(300) ["medium-height"]=> int(300) ["large"]=> string(96) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-1024x1024.jpg" ["large-width"]=> 整数(900) ["large-height"]=> 整数(900) } }
左上角截图
自定义字段截图
如何删除此文本?是不是出错了?
这里添加了正确的代码
<?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 } ;?>