admin管理员组文章数量:1023220
I am trying to get the terms from all the taxonomies in an array. but this throws an error like this ..not sure why. Is it the wrong method?:
Fatal error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
I am trying to get the terms from all the taxonomies in an array. but this throws an error like this ..not sure why. Is it the wrong method?:
Fatal error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
Share
Improve this question
asked Apr 29, 2019 at 7:12
user145078user145078
1
|
2 Answers
Reset to default 1This is a PHP syntax error. You're attempting to pass an array to get_terms()
but haven't used array()
or []
to make it an array. This means that =>
is invalid here. The code should be:
public function pggggo_list_of_terms() {
$terms = get_terms(
[
'taxonomy' => [
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras',
],
]
);
return $terms;
}
or
public function pggggo_list_of_terms() {
$terms = get_terms(
array(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras',
),
)
);
return $terms;
}
May be you are trying to do this. Passing arguments is wrong in your code.
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy', array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
I am trying to get the terms from all the taxonomies in an array. but this throws an error like this ..not sure why. Is it the wrong method?:
Fatal error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
I am trying to get the terms from all the taxonomies in an array. but this throws an error like this ..not sure why. Is it the wrong method?:
Fatal error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
Share
Improve this question
asked Apr 29, 2019 at 7:12
user145078user145078
1
-
You forgot about
array(
before'taxonomy'
. – nmr Commented Apr 29, 2019 at 7:15
2 Answers
Reset to default 1This is a PHP syntax error. You're attempting to pass an array to get_terms()
but haven't used array()
or []
to make it an array. This means that =>
is invalid here. The code should be:
public function pggggo_list_of_terms() {
$terms = get_terms(
[
'taxonomy' => [
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras',
],
]
);
return $terms;
}
or
public function pggggo_list_of_terms() {
$terms = get_terms(
array(
'taxonomy' => array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras',
),
)
);
return $terms;
}
May be you are trying to do this. Passing arguments is wrong in your code.
public function pggggo_list_of_terms(){
$terms = get_terms(
'taxonomy', array(
'vehicle_safely_features',
'vehicle_exterior_features',
'vehicle_interior_features',
'vehicle_extras')
);
return $terms;
}
本文标签: custom taxonomygetterms()unexpected 39gt39 (TDOUBLEARROW) error
版权声明:本文标题:custom taxonomy - get_terms() - unexpected '=>' (T_DOUBLE_ARROW) error 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745542649a2155253.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
array(
before'taxonomy'
. – nmr Commented Apr 29, 2019 at 7:15