我尝试使用以下代码检查数组是否存在,问题是当其中没有图像getFieldOrder('image_gal')
时会返回此错误。
错误输出
Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/sritamac/public_html/wp-content/plugins/magic-fields/get-custom.php on line 306
Warning: sort() expects parameter 1 to be array, null given in /home/sritamac/public_html/wp-content/plugins/magic-fields/get-custom.php on line 307
数组代码:
<?php
//var
$images = getFieldOrder('image_gal');
if (is_array($images)) {
foreach ($images as $image) {
if (get('image_gal', 1, $image) == TRUE) { //check if image_gallery_image has image
?>
<div id="wrap">
<ul id="mycarousel" class="jcarousel-skin-tango">
<?php
$images = getFieldOrder('image_gal');
foreach ($images as $image) { //loop image
?>
<li>
<a class="group3" href="<?php echo get('image_gal', 1, $image);?>">
<img src="<?php echo get('image_gal', 1, $image);?>" width="150" height="150" alt="" />
</a>
</li>
<?php
}
?>
</ul>
</div>
<?php
break;
}
}
}
?>
我使用这个主题http://www.s5themes.com/theme/webfolio/和 wordpress 版本是 3.2.1。