【问题标题】:Fatal error: Redefinition of parameter $post_id in C:\xampp\htdocs\wp-content\themes\couponer\functions.php on line 2533致命错误:在第 2533 行的 C:\xampp\htdocs\wp-content\themes\couponer\functions.php 中重新定义参数 $post_id
【发布时间】:2017-12-05 19:39:05
【问题描述】:

我遇到错误

致命错误:重新定义参数 $post_id in C:\xampp\htdocs\wp-content\themes\couponer\functions.php 在第 2533 行

function coupon_smeta_images( $meta_key, $post_id, $default, $post_id){
    if(class_exists('SM_Frontend')){
        global $sm;
        return $result = $sm->sm_get_meta($meta_key, $post_id);
    }
    else{       
        return $default;
    }
}

/* check if smeta plugin is installed */

【问题讨论】:

  • 你的函数构造中有两次$post_id
  • 如前所述,您使用$post_id 作为此函数的两个单独参数。虽然我也有点担心它在第 2533 行,但可能一个文件中的代码太多?
  • 这是一个Wordpress主题功能文件。我不知道如何解决这个错误你能提出一些建议
  • 函数 coupon_smeta_images($meta_key, $post_id, $default, $post_id)

标签: php wordpress


【解决方案1】:

您的函数中有重复的$post_id 参数。尝试删除一个这样的:

function coupon_smeta_images( $meta_key, $post_id, $default){
    if(class_exists('SM_Frontend')){
        global $sm;
        return $result = $sm->sm_get_meta($meta_key, $post_id);
    }
    else{       
        return $default;
    }
}

【讨论】:

    猜你喜欢
    • 2014-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 2020-06-08
    • 2016-01-01
    • 2021-06-06
    • 2015-11-18
    相关资源
    最近更新 更多