WP精选图片URI而不是自定义字段

问题描述:

我处于一种主题,我无法依赖wordpress中的自定义字段,而需要使用“精选图片”功能。WP精选图片URI而不是自定义字段

这是调用自定义字段

<?php $thumbnail_image = get_post_meta($post->ID, 'post-image', true); ?> 

我找不到在WordPress抄本“特色形象”的任何文件的代码,但是它可以调用的功能图像的URL这个例子中的一个页面?

这应该让你去 http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

编辑:

$image_attributes = wp_get_attachment_image_src(get_post_thumbnail_id()); 
$image_src = $image_attributes[0]; 
+0

玩这个,我只能得到一个图像元素没有src属性,不知道这是怎么回事工作。 – stephenway 2011-04-15 01:19:41

+0

编辑我的原始答案 – 2011-04-15 01:24:38

+0

我将大小参数添加到wp_get_attachment_image_src,它的工作方式就像一个魅力。谢谢! – stephenway 2011-04-15 03:08:11