我有这个产生警告的 PHP 代码:
Warning: Invalid argument supplied for foreach() php wordpress
这是代码:
<?php
$post_status1 = 'publish';
$post_type1 = 'page';
$featucat = "about";
$featucount = "1";
$my_query = new WP_Query('post_status='. $post_status1 .'&post_type='. $post_type1.'');
if ($my_query->have_posts()){
while ($my_query->have_posts()) : $my_query->the_post();
$front_values = get_post_custom_values('Homepage_Blog_01p', get_the_ID());
foreach ( $front_values as $front_key => $result_value ) {
if($result_value == 'about') {
?>
<div class="thewidgets">
<?php
$description_values = get_post_custom_values('Description_Field', get_the_ID());
foreach ( $description_values as $description_key => $description_value ) {
echo $description_value;
}
?>
<a href="<?php the_permalink(); ?>" title="Read the whole post" class="rm">Read More</a>
</div>
<?php } } endwhile; } ?>
这是完整的错误:
Warning: Invalid argument supplied for foreach() in
D:\PROGRAM FILES\wamp\www\westchester\wp-content\themes\
computerrepair\footer.php on line 22"
我究竟做错了什么?