Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress';非法字符串偏移量';更新后_Php_Html_Wordpress_Debugging_Wordpress Theming - Fatal编程技术网

Php Wordpress';非法字符串偏移量';更新后

Php Wordpress';非法字符串偏移量';更新后,php,html,wordpress,debugging,wordpress-theming,Php,Html,Wordpress,Debugging,Wordpress Theming,我的新客户有一个网站很久没有更新了。现在PHP版本、wordpress版本和插件都是最新的,但Portifolio项目现在返回以下错误: 截图: 警告:中的字符串偏移量“alt”非法 /home/elite856/public_html/wp content/themes/eliteled/functions.php on 第679行 警告:中的字符串偏移量“url”非法 /home/elite856/public_html/wp content/themes/eliteled/functio

我的新客户有一个网站很久没有更新了。现在PHP版本、wordpress版本和插件都是最新的,但Portifolio项目现在返回以下错误:

截图:

警告:中的字符串偏移量“alt”非法 /home/elite856/public_html/wp content/themes/eliteled/functions.php on 第679行

警告:中的字符串偏移量“url”非法 /home/elite856/public_html/wp content/themes/eliteled/functions.php on 第679行

这是第679行:

'<img src="'. $ob_img['url'] .'" class="capa" alt="'. $ob_img['alt'] .'" />'.
$portfolio = new WP_Query( $args );

if( $portfolio->have_posts() ){
    while ( $portfolio->have_posts() ) { $portfolio->the_post();

        $ob_img     = get_field( 'imagem_de_capa' );
        $allcats    = get_the_category( get_the_ID() );
        $cat        = $allcats[0]->name;
        $arrayData  = array(
                        'id'        => get_the_ID(),
                        'Titulo'    => get_the_title(),
                        'cat'       => $cat
                    );

        //Criando arrayData com as informações do portfolio
        if( have_rows('conteudo_do_portfolio') ){
            while( have_rows('conteudo_do_portfolio') ){ the_row();

                $tipo = get_field( 'tipo' );

                if( $tipo == 'foto' ){

                    if( empty( $arrayData['imgs'] ) ){
                        $arrayData['imgs'][] = array(
                            'full' => $ob_img['original_image']['url'],
                            'thumb' => wp_get_attachment_image_src( $ob_img['id'], 'thumb_portfolio' )[0]
                        );
                    }

                    $idImg      = get_sub_field('foto');

                    $arrayData['imgs'][] = array(
                        'full' => wp_get_attachment_image_src( $idImg, 'full' )[0],
                        'thumb' => wp_get_attachment_image_src( $idImg, 'thumb_portfolio' )[0]
                    );

                }else{

                    $idVideo = youtube_video_id( get_sub_field('video') );

                    $arrayData['imgs'][] = array(
                        'full'  => $idVideo,
                        'thumb' => "http://img.youtube.com/vi/{$idVideo}/0.jpg"
                    );

                }

            }
        }

        //'<li class="'. ( is_home() || is_front_page() ? 'item-home' : '' ) .'">'
        $conteudo .=    '<li>'.
                        '<img src="'. $ob_img['url'] .'" class="capa" alt="'. $ob_img['alt'] .'" />'.
                        '<div class="camada text-center">'.
                            '<a href="#" class="openModalPortfolio" data-tipo="'. get_field( 'tipo' ) .'" data-json=\''. json_encode( $arrayData ) .' \'\ >'.
                                //'<div class="'. ( is_home() || is_front_page() ? 'center-home' : 'center' ) .'">'.
                                '<div class="center">'.
                                    //'<img src="/wp-content/themes/eliteled/images/expand'. ( is_home() || is_front_page() ? '' : '-red' ) .'.png" class="expand" />'.
                                    '<img src="/wp-content/themes/eliteled/images/expand-red.png" class="expand" />'.
                                    '<span class="titulo">'. ( strlen( get_the_title() ) > 60 ? substr( get_the_title(), 0, 60 ) . '...' : get_the_title() ) .'</span>'.
                                    '<span class="cat">'. $cat .'</span>'.
                                '</div>'.
                            '</a>'.
                        '</div>'.
                        '<div class="camada camada-branca"></div>'.
                    '</li>';

    }
}
''。
这是整个功能:

'<img src="'. $ob_img['url'] .'" class="capa" alt="'. $ob_img['alt'] .'" />'.
$portfolio = new WP_Query( $args );

if( $portfolio->have_posts() ){
    while ( $portfolio->have_posts() ) { $portfolio->the_post();

        $ob_img     = get_field( 'imagem_de_capa' );
        $allcats    = get_the_category( get_the_ID() );
        $cat        = $allcats[0]->name;
        $arrayData  = array(
                        'id'        => get_the_ID(),
                        'Titulo'    => get_the_title(),
                        'cat'       => $cat
                    );

        //Criando arrayData com as informações do portfolio
        if( have_rows('conteudo_do_portfolio') ){
            while( have_rows('conteudo_do_portfolio') ){ the_row();

                $tipo = get_field( 'tipo' );

                if( $tipo == 'foto' ){

                    if( empty( $arrayData['imgs'] ) ){
                        $arrayData['imgs'][] = array(
                            'full' => $ob_img['original_image']['url'],
                            'thumb' => wp_get_attachment_image_src( $ob_img['id'], 'thumb_portfolio' )[0]
                        );
                    }

                    $idImg      = get_sub_field('foto');

                    $arrayData['imgs'][] = array(
                        'full' => wp_get_attachment_image_src( $idImg, 'full' )[0],
                        'thumb' => wp_get_attachment_image_src( $idImg, 'thumb_portfolio' )[0]
                    );

                }else{

                    $idVideo = youtube_video_id( get_sub_field('video') );

                    $arrayData['imgs'][] = array(
                        'full'  => $idVideo,
                        'thumb' => "http://img.youtube.com/vi/{$idVideo}/0.jpg"
                    );

                }

            }
        }

        //'<li class="'. ( is_home() || is_front_page() ? 'item-home' : '' ) .'">'
        $conteudo .=    '<li>'.
                        '<img src="'. $ob_img['url'] .'" class="capa" alt="'. $ob_img['alt'] .'" />'.
                        '<div class="camada text-center">'.
                            '<a href="#" class="openModalPortfolio" data-tipo="'. get_field( 'tipo' ) .'" data-json=\''. json_encode( $arrayData ) .' \'\ >'.
                                //'<div class="'. ( is_home() || is_front_page() ? 'center-home' : 'center' ) .'">'.
                                '<div class="center">'.
                                    //'<img src="/wp-content/themes/eliteled/images/expand'. ( is_home() || is_front_page() ? '' : '-red' ) .'.png" class="expand" />'.
                                    '<img src="/wp-content/themes/eliteled/images/expand-red.png" class="expand" />'.
                                    '<span class="titulo">'. ( strlen( get_the_title() ) > 60 ? substr( get_the_title(), 0, 60 ) . '...' : get_the_title() ) .'</span>'.
                                    '<span class="cat">'. $cat .'</span>'.
                                '</div>'.
                            '</a>'.
                        '</div>'.
                        '<div class="camada camada-branca"></div>'.
                    '</li>';

    }
}
$portfolio=新的WP\u查询($args);
如果($portfolio->have_posts()){
而($portfolio->have_posts()){$portfolio->the_post();
$ob_img=get_字段('imagem_de_capa');
$allcats=get_类别(get_ID());
$cat=$allcats[0]->名称;
$arrayData=数组(
'id'=>获取\u id(),
“Titulo”=>获取标题(),
'猫'=>$cat
);
//Criando arrayData com作为informações的投资组合
如果(有行('conteudo\u do\u公文包')){
而(have_row('conteudo_do_公文包'){the_row();
$tipo=get_字段('tipo');
如果($tipo=='foto'){
if(空($arrayData['imgs'])){
$arrayData['imgs'][]=数组(
“完整”=>$ob\u img['original\u image']['url'],
“thumb”=>wp\u get\u attachment\u image\u src($ob\u img['id'],'thumb\u portfolio')[0]
);
}
$idImg=获取子字段('foto');
$arrayData['imgs'][]=数组(
'full'=>wp_get_attachment_image_src($idImg,'full')[0],
'thumb'=>wp_get_attachment_image_src($idImg,'thumb_portfolio')[0]
);
}否则{
$idVideo=youtube_video_id(获取子字段('video'));
$arrayData['imgs'][]=数组(
“完整”=>$idVideo,
“拇指”=>“http://img.youtube.com/vi/{$idVideo}/0.jpg“
);
}
}
}
//“
  • ” $conteudo.='
  • '。 ''. ''. ''. ''. ''. “
  • ”; } }

    我已经读到,在PHP5.4之前,这个警告通常不会像那样打印出来,而且它之所以会出现,是因为它需要一个数组。我有点PHP技能,有人能告诉我怎么做吗?

    根据转储的数据,我猜
    原始图像的内容是一个附件ID,请尝试以下方法:

    $img_params = json_decode($ob_img, true); // convert string to associative array
    $url = wp_get_attachment_image_url($img_params['original_image']);
    if ($url) {
      // we have the image url now so display the image here tag here
    }
    

    如果它不起作用,请检查原始主题/插件开发人员,如果此组合来自的插件/主题有新的更新

    尝试
    var\u dump($ob\u img)
    并查看它包含的内容。string(48)“{”original\u image:“6585”,“crapped\u image:“6585”}”,然后
    $ob img['url']
    $ob img['alt']
    不存在。这就是PHP显示该消息的原因。那么我能做什么呢?它在我更新之前就开始工作了对不起,我可能真的缺乏这方面的知识…我应该在代码中的什么地方使用你的建议?我似乎无法让它工作。