我试图让我的Wordpress主题为我在指定为'图像'的字段中添加到帖子中的自定义字段中指定的索引页上列出的每个帖子拉起缩略图。无论出于什么原因,get_post_meta()函数都不会返回任何东西,请尽量尝试。我究竟做错了什么?Wordpress - get_post_meta()函数不返回值?
下面的代码:
<?php while (have_posts()) : the_post(); ?>
<div class="posts-wrapper">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<img src="<?php get_post_meta($post->ID, 'image', true); ?>">
</div>
<?php endwhile; ?>
如果我将代码更改为get_post_meta(the_id(),'image',true); - 然后它只输出帖子ID。例如,我的一个帖子只是输出链接为“6”。 – Sootah 2011-01-08 08:09:49