从我在那里看到的情况来看,我认为您的问题是story\\u detail\\u story\\u image中的元值正在存储图像id。
尝试替换以下内容
<?php if ( get_post_meta( get_the_ID(), \'story_detail_story_image\', true ) ) : ?>
<a href="<?php the_permalink() ?>" rel="bookmark">
<img class="thumb" src="<?php echo get_post_meta( get_the_ID(), \'story_detail_story_image\', true ); ?>" alt="<?php the_title(); ?>" />
</a>
<?php endif; ?>
具有以下内容
<?php
$image_id = get_post_meta( get_the_ID(), \'story_detail_story_image\', true );
if ( ! is_int( $image_id ) ) {
echo "<p>Image ID not an integer. It is:</p><pre>"; var_dump( $image_id ); echo "</pre>";
} else if ( $image_id ) {
# The next line tries to grab an image with that id in thumbnail size
$image_data = wp_get_attachment_image_src( $image_id, \'thumbnail\' );
if ( ! is_array( $image_data ) ) {
echo "<p>Image data not an array! It is:</p><pre>"; var_dump( $image_data ); echo "</pre>";
} else if ( is_array( $image_data ) ) {
# The next line grabs the url, which is stored in the first element of the array
$image_url = $image_data[0];
# the next three lines just grab post information
$post_id = get_the_ID();
$post_title = esc_attr( get_the_title() );
$post_link = get_permalink();
# The following displays the link. I just prefer heredoc syntax but you should be able to change it back if wanted
echo <<<HTML
<a href="{$post_link}" rel="bookmark">
<img class="thumb" src="{$image_url}" alt="{$post_title}" />
</a>
HTML;
}
}
?>
这应该获取图像id,使用它获取url,然后绘制链接。
(修改为输出错误)。