简体   繁体   English

来自“高级自定义字段”的回显图像URL

[英]Echo image url from Advanced Custom Fields

I'm trying to return the url of an image that was uploaded to a post of a certain taxonomy (created by the IssueM plugin), using Advance Custom Fields plugin for WP. 我正在尝试使用WP的Advanced Custom Fields插件返回上传到某个分类法(由IssueM插件创建)的帖子的图像的URL。 I set the rule to 'show this field group if the Taxonomy Term is equal to Issues'. 我将规则设置为“如果分类术语等于问题,则显示此字段组”。 The code I am using is thus: 因此,我正在使用的代码是:

    <div class="article-cover clearfix" style="background:url('<?php 
$image = get_field('toc_img');
echo $image['url']; ?>') center center;background-size:cover;">
</div>

I want it to return the URL, which is something like 我希望它返回URL,类似于

http://www.mywebsite.com/wp-content/uploads/sites/2014/image.jpg http://www.mywebsite.com/wp-content/uploads/sites/2014/image.jpg

Instead it returns something that looks like the area the image was uploaded in, which is 而是返回类似于图片上传区域的内容,即

http://www.mysite/the-itinerant/articles/?issue=the-itinerant-01 http://www.mysite/the-itinerant/articles/?issue = the-itinerant-01

The Advance Custom Fields image upload is designed to upload an image to a specific 'issue', which is a custom taxonomy created by the IssueM plugin. “高级自定义字段”图像上载旨在将图像上载到特定的“问题”,这是由IssueM插件创建的自定义分类法。 I have successfully uploaded the image to Issue 01, which this URL suggests. 我已成功将图像上传到该URL建议的版本01。 I just can't return the correct path. 我只是无法返回正确的路径。

Ultimately this bit of code should return the relevant image to the relevant issue. 最终,这段代码应使相关图像返回相关问题。

Can'y you just simply call the ACF for the image as such: 您能否简单地这样调用图像的ACF:

<?php the_field('toc-img'); ?>

That would give you the url of the image 那会给你图片的网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM