I am trying to fix a PHP error for adding extra fields to WordPress categories. But it gives this error:   

> 
> Trying to get property of non-object in
>  D:\MAMP\htdocs\client\wp-content\themes\custom\_t\extra\_category\_fields.php on line 7
> 
> 
> 

Here is my code:

```
<?php
add_action('edit_category_form_fields', 'extra_category_fields');
add_action ( 'category_add_form_fields', 'extra_category_fields');//adds 
same fields to add new cat
//add extra fields to category edit form callback function
function extra_category_fields($tag) {    //check for existing featured ID
$t_id = $tag->term_id;
$cat_meta = get_option( "category_$t_id");

```

The error is on line 7 which has this code: `$t_id = $tag->term_id;`

I shall appreciate if someone gives me a solution to this php error.

P.S. I do not consider myself an expert in PHP. I already checked this article: [Reference - What does this error mean in PHP](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/26572398#26572398) but I still could not understand a direct solution.

Thank you!