[英]Wordpress custom fields displaying image name
我有一個自定義字段,用戶可以在其中選擇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”] => int(35)[“ alt”] =>字符串(0)“” [“標題”] =>字符串(28)“ 4c5a6729201043.55e72a8144693” [“標題”] =>字符串(0)“” [“”“” =>字符串(0)“” [“ mime_type”] =>字符串(10)“圖像/ jpeg” [“ URL”] =>字符串(86)“ http :// localhost:1337 / kite / wp-content / uploads / 2015/11 / 4c5a6729201043.55e72a8144693.jpg “ [” width“] => int(1200)[” height“] => int(1200)[”尺寸“] => array(9){[”“縮略圖”] => string(94)“ http:// localhost:1337 / kite / wp-content / uploads / 2015/11 / 4c5a6729201043.55e72a8144693-150x150.jpg ” [ “ thumbnail-width”] => int(150)[“ thumbnail-height”] => int(150)[“ medium”] =>字符串(94)“ http:// localhost:1337 / kite / wp-content /uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg “ [”中等寬度“] => int(300)[”中等高度“] => int(300)[”大“] =>字符串( 96)“ http:// localhost:1337 / kite / wp-content / uploads / 2015/11 / 4c5a6729201043.55e72a8144693-1024x1024.jpg ” [“大寬度”] => int(900)[“大高度” ] => int(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 } ;?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.