我有4行错误与下面完全相同:
尝试获取非对象的属性 /home/sgclass/public_html/wp-content/themes/socialchef-child/includes/plugins/frontend-submit/frontend-submit.php 在1168行
第1168行的代码是:
$recipe_difficulties_str .= "{$recipe_difficulty->term_id}:{$recipe_difficulty->name},";
有什么问题吗?
环绕声代码如下。
$this->form_fields[] = (object)array( 'type' => 'div', 'class' => 'third', 'is_closing' => false );
$taxonomies = array( 'recipe_difficulty2' );
$recipe_difficulties = get_terms($taxonomies, $args);
$recipe_difficulties_str = ':' . __('Select difficulty 2', 'socialchef-child') . ',';
//echo "dificulty2 value:";
//var_dump( wp_get_post_terms( '1189', 'recipe_difficulty2' ) );
foreach ($recipe_difficulties as $recipe_difficulty) {
**$recipe_difficulties_str .= "{$recipe_difficulty->term_id}:{$recipe_difficulty->name},";**
}
$recipe_difficulties_str = rtrim($recipe_difficulties_str, ',');
$difficulty_field = array( 'type' => 'select', 'role' => 'internal', 'name' => 'recipe_difficulty2', 'id' => 'fes_recipe_difficulty2', 'description' => __( 'Select difficulty 2', 'socialchef-child' ), 'values' => $recipe_difficulties_str, 'class' => 'select' );
if ($this->entry != null) {
$difficulty_field['value'] = $this->get_entry_field_value('recipe_difficulty2');
}
$this->form_fields[] = (object)$difficulty_field;
$this->form_fields[] = (object)array( 'type' => 'div', 'class' => '', 'is_closing' => true );
答案 0 :(得分:0)
我认为您的结果数据不是对象,但您尝试将其作为对象检索,因此请尝试将其作为数组进行检索。
$recipe_difficulties_str .= "{$recipe_difficulty['term_id'] }:{$recipe_difficulty['name'] },";
注意:但您应该在检索数据之前打印$ recipe_difficulty。