Warning: array_shift() expects parameter 1 to be array, object given in /hermes/walnaweb01a/b1374/moo.peachdesigninccom/tools4hardwood/wp-content/themes/listings/homepage_loops/content-listingsum.php on line 18
是我在這頁上得到的錯誤http://www.tools4hardwoods.com/home-2/,我沒有運氣。有人能幫我調試嗎?PHP警告:array_shift()期望參數1是數組
繼承人的全碼:
<div class="car-list">
<div class="car-img">
<?php if(has_post_thumbnail()): ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail("home_listing"); ?></a>
<?php endif; ?>
</div>
<div class="car-info">
<a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>
<h2 class="car-price"><?php get_listing_price(); ?></h2>
<ul class="car-tags clear">
<?php
global $post;
$configuration = get_listing_display_attributes($post->ID);
if ($configuration):
foreach ($configuration as $tax) {
$terms = get_the_terms($post->ID,$tax);
if ($terms):
$term = array_shift($terms);
$term_link = get_term_link($term->slug,$term->taxonomy);
$term_name = $term->name;
$taxonomy = get_taxonomy($term->taxonomy);
?>
<a href="<?php echo $term_link; ?>"><?php echo $term_name; ?></a>
<?php
endif;
}
endif;
?>
</ul>
</div>
<div style="clear:both;"></div>
</div>
如果你使用'print_r($ terms)',你會得到什麼?這不是一個數組。 WP說它可能會返回錯誤。 – Popnoodles
dewalt手搖砂光機79美元? –
你可以把你的建議放在完整的代碼中,或者至少讓我知道哪一行代碼替換它? – kgmack