2011-12-05 128 views
0

我正在使用ACF,因此用戶可以將圖像上載到預定義的位置並相應地分配頁面規則。在WP後端上,一切似乎都很順利,將三張圖片上傳到了字段中。但是,在字體結尾處,除了空白框外,沒有任何東西出現在所有圖像應該在的位置。望着那WP的輸出源,只有空白代碼:高級自定義字段Wordpress插件 - 圖像不顯示

<img src="" class="middle" alt="image1"/> 

這是我使用的循環:

<?php query_posts("posts_per_page=1&post_type=page&page_id=168"); if (have_posts()) : 
while (have_posts()) : 
    the_post(); ?> 
<!--If you want to refer to the child of parent page, use "post_parent=" --> 
<li> 
    <h3><?php the_title(); ?></h3> 
    <?php the_excerpt(); ?> 
    <img src="<?php the_field('image_1'); ?>" class="middle" alt="image1"/> 
    <a href="<?php the_permalink(); ?>" class="button">View More</a> 
</li> 
    <?php endwhile; ?> 
      <!-- post navigation --> 
     <?php else: ?> 
      <!-- no posts found --> 
     <?php endif; ?> 
     <?php wp_reset_query(); ?> 

重要的是要注意,我不拉的圖像是非常重要的另一頁。我只想讓圖片與我正在處理的模板&相關。

+0

它顯然是the_field()的問題,什麼是the_field(),你是怎麼寫這個函數的? – bingjie2680

+0

你以前用過這個插件嗎? the_field是標準的。 – tobeeornot

回答

0

我只是需要提名主頁ID功能:

<img src="<?php the_field('image_2', '245'); ?>" class="middle" alt="image2"/> 
0

可以使用get_the_field()獲取字段的正確的價值,

<img src="<?php get_the_field('image_1'); ?>" class="middle" alt="image1"/> 
1

確保圖像場輸出圖片鏈接的ID或網址。

<?php if(get_field('YOUR FIELD NAME')): while(has_sub_field('YOUR FIELD NAME')): ?> 
     <img class="logo" src="<?php the_sub_field('image_1'); ?>" /> 
    <?php endwhile; endif; ?> 
相關問題