cod*_*dek 3 php wordpress field
我正在使用wordpress的网站上工作,我正试图从帖子的高级自定义字段中获取缩略图:
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_field('custom_title'); ?></h1>
<img src="<?php the_field('thumbnail'); ?>" alt="" />
<p><?php the_content(); ?></p>
<?php endwhile; // end of the loop. ?>
Run Code Online (Sandbox Code Playgroud)
问题是,当我加载网站时,图像获取的网址如下所示:
<img src="5, , item_alt2, , , http://portfolio.local/wp-content/uploads/2012/09/item_alt2.jpg, Array">
Run Code Online (Sandbox Code Playgroud)
因此,据我所知,它正在寻找图像的插件,但它加载了一个奇怪的路径,所以它显示像"破碎"的图像.
我做错了什么?
5, , item_alt2, , , http://portfolio.local/wp-content/uploads/2012/09/item_alt2.jpg, ArrayNULL
Run Code Online (Sandbox Code Playgroud)
查看高级自定义字段的文档;
http://www.advancedcustomfields.com/docs/field-types/image/
您将自定义字段的值作为对象返回,如下面的示例所示;
Array
(
[id] => 540
[alt] => A Movie
[title] => Movie Poster: UP
[caption] => sweet image
[description] => a man and a baloon
[url] => http://localhost:8888/acf/wp-content/uploads/2012/05/up.jpg
[sizes] => Array
(
[thumbnail] => http://localhost:8888/acf/wp-content/uploads/2012/05/up-150x150.jpg
[medium] => http://localhost:8888/acf/wp-content/uploads/2012/05/up-300x119.jpg
[large] => http://localhost:8888/acf/wp-content/uploads/2012/05/up.jpg
[post-thumbnail] => http://localhost:8888/acf/wp-content/uploads/2012/05/up.jpg
[large-feature] => http://localhost:8888/acf/wp-content/uploads/2012/05/up.jpg
[small-feature] => http://localhost:8888/acf/wp-content/uploads/2012/05/up-500x199.jpg
)
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4099 次 |
| 最近记录: |