相关文章 WP 中的拇指错误


Related Post w/ Thumbs error in WP

我正在尝试使用以下PHP代码在single.php主帖子页面的末尾引入相关帖子。

EG: 主页>点击帖子>帖子页面(单个.php)> 内容下方是 3 个带有缩略图的相关帖子。

这是我正在尝试的:

<!-- Related Stories -->
<div class="postCategory" style="">Related Stories<br />

        <div class="clear"></div>
        <div style="width:100%;" align="center">
        <div style="width:495px;" align="center">    
            <?php foreach( $Featuredposts as $post ) : setup_postdata($post); ?>
            <?php //$do_not_duplicate[] = $post->ID;  //print("$do_not_duplicate"); ?>
            <?php if($featured_image=get_post_meta($post->ID, "featured_image", true)) { ?>  
            <div style="display:block; width:150px; margin:0 15px 0 0; float:left" align="center">
                <a class="oborder" href="<?php the_permalink() ?>"><img src="<?php echo $featured_image; ?>" heigh="124" width="143" border="0" /></a>            
                <span style="display:inline;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" style="display:inline;"><?php the_title(); ?></a></span>
            </div>    
            <?php }?>               
            <?php endforeach; ?>
            <div class="clear"></div>
       </div>
       </div>

 <!-- End Pull in Related Stories --> 

这是我得到的错误:

Warning: Invalid argument supplied for foreach() in /data/24/1/0/139/1815302/user/1967139/htdocs/RIF/wp-content/themes/crown_readitforward2012/single.php on line 280

第 280 行 = <div style="width:495px;" align="center"> ??

(当我删除它时 - 我在第 281 行出现错误)

281行= <?php foreach( $Featuredposts as $post ) : setup_postdata($post); ?>

print_r你的$Featuredposts以确保它有数据。

print_r($Featuredposts);