【问题标题】:count(): Parameter must be an array or an object that implements Countable in on line 8 [closed]count():参数必须是第 8 行中实现 Countable 的数组或对象 [关闭]
【发布时间】:2020-09-25 17:17:04
【问题描述】:
      <?php if($images && is_array($images) && count($images > 0)):
      foreach($images as $image): 
        $image_full_src = false; $image_thumb_src = false;
        if($image_full_src = wp_get_attachment_image_src($image, 'full')) $image_full_src = $image_full_src['0'];
        if($image_thumb_src = wp_get_attachment_image_src($image, 'thumbnail')) $image_thumb_src = $image_thumb_src['0']; 
      ?>

我该如何修复它? 它是用wordpress

【问题讨论】:

  • 这行有错字:count($images &gt; 0),应该是count($images) &gt; 0
  • 哇,非常感谢兄弟,这是正确的,谢谢...

标签: php wordpress


【解决方案1】:
 <?php if($images && is_array($images) && count($images) > 0):
  foreach($images as $image): 
    $image_full_src = false; $image_thumb_src = false;
    if($image_full_src = wp_get_attachment_image_src($image, 'full')) $image_full_src = $image_full_src['0'];
    if($image_thumb_src = wp_get_attachment_image_src($image, 'thumbnail')) $image_thumb_src = $image_thumb_src['0']; 
  ?>

【讨论】:

    猜你喜欢
    • 2019-05-10
    • 1970-01-01
    • 2019-01-06
    • 2021-05-30
    • 2018-06-28
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多