高级自定义字段Wordpress插件 - 图像不显示
问题描述:
我正在使用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(); ?>
重要的是要注意,我不拉的图像是非常重要的另一页。我只想让图片与我正在处理的模板&相关。
答
我只是需要提名主页ID功能:
<img src="<?php the_field('image_2', '245'); ?>" class="middle" alt="image2"/>
答
可以使用get_the_field()
获取字段的正确的价值,
<img src="<?php get_the_field('image_1'); ?>" class="middle" alt="image1"/>
答
确保图像场输出图片链接的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; ?>
它显然是the_field()的问题,什么是the_field(),你是怎么写这个函数的? – bingjie2680
你以前用过这个插件吗? the_field是标准的。 – tobeeornot