首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >请帮助我解决第51行/public_html/wp-content/themes/modus-child/functions.php中未定义的偏移量:0。

请帮助我解决第51行/public_html/wp-content/themes/modus-child/functions.php中未定义的偏移量:0。
EN

Stack Overflow用户
提问于 2021-03-08 14:59:39
回答 1查看 878关注 0票数 0

我继承了一个有问题的网站后,与他们原来的网站开发者沟通中断。

我一直在努力解决尽可能多的错误。

注意:第51行/home/customer/www/public_html/wp-content/themes/modus-child/functions.php中未定义的偏移量:0

长期的目标将是重建网站,使用一个不同的主题,但我会感谢一些帮助解决这一错误,以给我们一个安全网,而发展正在进行。

显示代码粘贴代码的屏幕截图看上去不正确

下面是第46行,第51行是以if($featured==“Featured”)开头的行,{我可以在括号中看到偏移量0。

代码语言:javascript
复制
$count=0;
      foreach ($woo_catgery as $sc) {
            $count++;
            if($count==6){continue;}
            $featured = get_field('featured', $sc->taxonomy . '_' . $sc->term_id);
            if($featured[0]=="Featured"){
            $thumbnail_id = get_term_meta( $sc->term_id, 'thumbnail_id', true );
            $image_url=wp_get_attachment_url( $thumbnail_id ); 
            if(!empty($image_url)){
                $image_url=$image_url;
            }else{$image_url=get_stylesheet_directory_uri().'/img/blank.png';}
            $link = get_term_link( $sc->slug, $sc->taxonomy );
            $hm .='<li>
                    <div class="cat_image">
                        <a href="'. $link .'" title="" target="_self">        
                            <img alt="icon" src="'.$image_url.'">
                        </a>                    
                    </div>
                    <div class="cat_bx_cnt">
                        <div class="cat_ttl">
                            <h3 class="cat_ttl_mn">'.$sc->name.'</h3>                      
                        </div>
                        <a class="link-more" href="'. $link .'" title="" target="_self">
                            <i class="fa fa-angle-right" aria-hidden="true"> </i>
                        </a>
                    </div>
                </li>               
            '; 
            }
      }
      $hm .='</ul>';
      return $hm;
    
}
add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );

add_action( 'after_setup_theme', 'remove_pgz_theme_support', 100 );

function remove_pgz_theme_support() { 
remove_theme_support( 'wc-product-gallery-zoom' );
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-08 15:05:44

$featured似乎是一个空数组,因此您应该首先检查它是否包含元素:

代码语言:javascript
复制
if(count($featured) > 0 && $featured[0]=="Featured")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66532099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档