我工作在WordPress网站上,我想从一个岗位的高级定制领域的缩略图,这样的:高级自定义字段缩略图 - 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. ?>
那就是当问题我加载网页,图像变得看起来像这样的网址:
<img src="5, , item_alt2, , , http://portfolio.local/wp-content/uploads/2012/09/item_alt2.jpg, Array">
所以,据我看到的,因为容貌的图像它的工作的插件,但它会加载一个奇怪的路径,因此它显示像“破碎”的图像。
我做错了什么?
5, , item_alt2, , , http://portfolio.local/wp-content/uploads/2012/09/item_alt2.jpg, ArrayNULL
,只要看一眼,不知道WordPress的那么好,你用'the_field调用的方式(“缩略图')'以字符串形式返回一个逗号分隔的列表,缩略图*可能*在索引#5处(零是第一个)。因此,要么将错误的值传递给函数,要么以某种方式解析(''thumb = explode(',',the_field('thumbnail'));',然后使用'$ thumb [5 ]')或类似的东西。 –
the_field('thumbnail')这是调用高级自定义字段插件功能的方法 – codek
是否调用'the_field('custom_title');'返回适当的值,即“我的自定义标题”? – tftd