I'm getting an error:
Trying to get property of non-object on line 30
On the commented line below...
function admin_trim_category_description( $terms, $taxonomies ){
if( 'category' != $taxonomies[0] ) return $terms;
$my_categories = array('item1','item2','item3');
foreach( $terms as $key => $term)
if(in_array(
$terms[$key]->name, //ERROR LINE HERE
$my_categories))
{
unset($terms[$key]);
}
}
What am I doing wrong?
$terms[$key]
seems not to be an object. I'd suggest you to check whatever it is an object or not with:
if (is_object($terms[$key])) { /* OK */ }
and/or check whatever the object is an instance of a specific class with:
if ($terms[$key] instanceof MyClass) { /* OK */ }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.