我試圖讓我的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