【发布时间】:2016-01-21 06:24:10
【问题描述】:
我正在尝试使我的主题完全独立于 ACF 的 get_field 和 the_field(所以如果插件被禁用,网站不会中断)。我有一个通过自定义字段'slider_image' 作为内联background-image 加载的图像。我需要调用图像的 URL。是否可以将其加载到内联的 html 中?这是工作代码(带有 ACF 的 the_field):
<!-- Hero Image -->
<section class="hero" style="background: url('<?php the_field('slider_image'); ?>') no-repeat center center; background-size: cover;">
</section>
<!-- End Hero Image -->
如果插件被禁用,我如何使用get_post_meta重写此语句?
我试过了:
<section class="hero" style="background: url('<?php echo get_post_meta( get_the_ID(), 'slider_image', true ); ?>') no-repeat center center; background-size: cover;">
返回:
<section class="hero" style="background: url('98') no-repeat center center; background-size: cover;">
【问题讨论】:
标签: php wordpress advanced-custom-fields