多语言站点上的hreflang php函数问题

多语言站点上的hreflang php函数问题,php,wordpress,function,hreflang,Php,Wordpress,Function,Hreflang,我的一位客户要求我解决为什么他们的Wordpress网站在加载时出现问题。 他们的网站是由不同的开发人员创建的,不再与我的客户做生意,因此向他们寻求帮助是一个问题 在调查原因时,我发现以下PHP错误: [09-Jan-2017 04:09:52 UTC]PHP致命错误:无法在第121行的/home/***********/public_html/fr/wp content/themes/***************/functions.PHP中的写入上下文中使用函数返回值 查看function

我的一位客户要求我解决为什么他们的Wordpress网站在加载时出现问题。 他们的网站是由不同的开发人员创建的,不再与我的客户做生意,因此向他们寻求帮助是一个问题

在调查原因时,我发现以下PHP错误:

[09-Jan-2017 04:09:52 UTC]PHP致命错误:无法在第121行的/home/***********/public_html/fr/wp content/themes/***************/functions.PHP中的写入上下文中使用函数返回值

查看functions.php文件时,我发现以下代码:

function bs_get_hreflang_tags() {
    ob_start();
    if( !empty( get_field('australia', get_the_ID() ) ) ) : ?>
        <link rel="alternate" href="<?php echo esc_url( get_field('australia', get_the_ID() ) ); ?>" hreflang="en-au" />
    <?php endif;
    if( !empty( get_field('france', get_the_ID() ) ) ) : ?>
        <link rel="alternate" href="<?php echo esc_url( get_field('france', get_the_ID() ) ); ?>" hreflang="fr"/>
    <?php endif;
    if( !empty( get_field('spain', get_the_ID() ) ) ) : ?>
        <link rel="alternate" href="<?php echo esc_url( get_field('spain', get_the_ID() ) ); ?>" hreflang="es" />
    <?php endif;
    if( !empty( get_field('italy', get_the_ID() ) ) ) : ?>
        <link rel="alternate" href="<?php echo esc_url( get_field('italy', get_the_ID() ) ); ?>" hreflang="it" />
    <?php endif;

    $output = ob_get_contents();
    ob_end_clean();

    return $output;
}
函数bs\u get\u hreflang\u tags(){
ob_start();
如果(!empty(get_字段('australia',get_ID())):?>

ob的构造是不必要的复杂。。 试着用这个替换它

function bs_get_hreflang_tags() {
    $output= '';
    if( get_field('australia', get_the_ID() ) ) :
        $output = '<link rel="alternate" href="'.esc_url( get_field('australia', get_the_ID() ) ) . '" hreflang="en-au" />';
    elseif( get_field('france', get_the_ID() ) ) :
        $output = '<link rel="alternate" href="'.esc_url( get_field('france', get_the_ID() ) ) . '" hreflang="fr" />';
    elseif( get_field('spain', get_the_ID() ) ) :
        $output = '<link rel="alternate" href="'.esc_url( get_field('spain', get_the_ID() ) ) . '" hreflang="es" />';
    elseif( get_field('italy', get_the_ID() ) ) :
        $output = '<link rel="alternate" href="'.esc_url( get_field('italy', get_the_ID() ) ) . '" hreflang="it" />';
    endif;

    return $output;
}
函数bs\u get\u hreflang\u tags(){
$output='';
如果(get_字段('australia',get_ID()):
$output='';
elseif(get_字段('france',get_ID()):
$output='';
elseif(get_字段('西班牙',get_ID()):
$output='';
elseif(获取字段('italy',获取ID()):
$output='';
endif;
返回$output;
}

哪一行是121?哎呀,抱歉忘了加上它。“如果(!empty(get_field('australia',get_the_ID())):?>”非常感谢。问题是由于空的没有正确计算,还是由于if语句的构造方式,或者两者兼而有之?抱歉,我只是希望了解更多关于这个问题的信息。