php非法字符串偏移,更新后的Wordpress"非法字符串偏移" - WordPress - srcmini

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

屏幕截图:

8bae2ce05b251b269c051dbbb036349c.png

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

这是第679行:

''. $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"

);

}

}

}

//'

'

$conteudo .= '

'.

''. $ob_img['alt'] .''.

'

'.

''.

//'

'.

'

'.

//'expand'.%20(%20is_home()%20%7C%7C%20is_front_page()%20?%20''%20:%20'-red'%20)%20.'.png'.

'expand-red.png'.

''. ( strlen( get_the_title() ) > 60 ? substr( get_the_title(), 0, 60 ) . '...' : get_the_title() ) .''.

''. $cat .''.

'

'.

''.

'

'.

'

'';

}

}

我已经读过这个警告过去不会像PHP 5.4之前那样打印, 而且它的发生是因为它是期望的和数组。我的PHP技能不高, 有人可以给我一个做什么的线索吗?

#1

根据转储的数据, 我猜测original_image的内容是附件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

}

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值